aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJozanLeClerc <bousset.rudy@gmail.com>2020-03-20 17:56:53 +0100
committerJozanLeClerc <bousset.rudy@gmail.com>2020-03-20 17:56:53 +0100
commit8cda46cc9c839fd8efc26f1ae95024c5abf7fb57 (patch)
tree2d86ece5708b05a71842ca16ed1013dee6cd26b7
parentOk almost (diff)
download42-cub3d-8cda46cc9c839fd8efc26f1ae95024c5abf7fb57.tar.gz
42-cub3d-8cda46cc9c839fd8efc26f1ae95024c5abf7fb57.tar.bz2
42-cub3d-8cda46cc9c839fd8efc26f1ae95024c5abf7fb57.tar.xz
42-cub3d-8cda46cc9c839fd8efc26f1ae95024c5abf7fb57.tar.zst
42-cub3d-8cda46cc9c839fd8efc26f1ae95024c5abf7fb57.zip
Bounce it
-rw-r--r--Makefile1
-rw-r--r--inc/cub3d_defines.h1
-rw-r--r--src/ft_draw_handweap.c34
-rw-r--r--src/ft_draw_life_bar.c6
4 files changed, 37 insertions, 5 deletions
diff --git a/Makefile b/Makefile
index 60c2e2d..1c666ce 100644
--- a/Makefile
+++ b/Makefile
@@ -154,6 +154,7 @@ CFLAGS += -Wall
CFLAGS += -Wextra
CFLAGS += -Werror
CFLAGS += -pedantic
+CFLAGS += -march=ivybridge -O2 -pipe
#--------------------------------------------------------------------------------------------------#
ifdef DEBUG
CFLAGS += ${DBG}
diff --git a/inc/cub3d_defines.h b/inc/cub3d_defines.h
index 7a86115..01fa291 100644
--- a/inc/cub3d_defines.h
+++ b/inc/cub3d_defines.h
@@ -271,5 +271,6 @@ enum
# define FT_STRT_LIFE 200
# define FT_TRAP_DAMAGE_AMOUNT 27
# define FT_HEAL_PACK_AMOUNT 19
+# define FT_BOUNCE_FACTOR 8
# endif
diff --git a/src/ft_draw_handweap.c b/src/ft_draw_handweap.c
index cdc5f5a..607cb9a 100644
--- a/src/ft_draw_handweap.c
+++ b/src/ft_draw_handweap.c
@@ -27,6 +27,31 @@ static void
cl->tweap[w_id].img_w * cl->tweap[w_id].tex_y + 2);
}
+static int16_t
+ ft_set_move(void)
+{
+ static int8_t more = 0;
+ static int8_t less = 39;
+
+ if (more < 38)
+ {
+ more += FT_BOUNCE_FACTOR;
+ return (more);
+ }
+ else
+ {
+ less -= FT_BOUNCE_FACTOR;
+ if (less < 1)
+ {
+ more = 0;
+ less = 39;
+ return (more);
+ }
+ return (less);
+ }
+}
+
+#include <libft.h>
void
ft_draw_handweap(t_cub *cl)
{
@@ -34,20 +59,25 @@ void
int32_t y_ratio;
int16_t x;
int16_t y;
+ int16_t move;
int8_t w_id;
w_id = cl->plist.handles_weapon;
w_id += (cl->plist.fire == 1) ? (1) : 0;
- x_ratio = (int32_t)((cl->tweap[w_id].img_w << 16) / cl->wlist.x_size) + 1;
- y_ratio = (int32_t)((cl->tweap[w_id].img_h << 16) / cl->wlist.y_size) + 1;
+ x_ratio = (int32_t)(((cl->tweap[w_id].img_w - 50) << 16) / cl->wlist.x_size) + 1;
+ y_ratio = (int32_t)(((cl->tweap[w_id].img_h - 50) << 16) / cl->wlist.y_size) + 1;
y = 0;
+ move = ft_set_move();
+ move = (cl->plist.fire == 1) ? (0) : (move);
while (y < (int16_t)cl->wlist.y_size)
{
cl->tweap[w_id].tex_y = ((y * y_ratio) >> 16);
+ cl->tweap[w_id].tex_y += move;
x = 0;
while (x < (int16_t)cl->wlist.x_size)
{
cl->tweap[w_id].tex_x = ((x * x_ratio) >> 16);
+ cl->tweap[w_id].tex_x += move / 4;
if (cl->tweap[w_id].ptr[cl->tweap[w_id].tex_x * 4 + 4 *
cl->tweap[w_id].img_h * cl->tweap[w_id].tex_y])
ft_put_weapon_image(w_id, y, x, cl);
diff --git a/src/ft_draw_life_bar.c b/src/ft_draw_life_bar.c
index 06ecf70..b90daa1 100644
--- a/src/ft_draw_life_bar.c
+++ b/src/ft_draw_life_bar.c
@@ -44,7 +44,7 @@ static void
x_ratio = (int)((cl->tnum[10].img_w << 16) / (7 * cl->mlist.scale)) + 1;
y_ratio = (int)((cl->tnum[10].img_h << 16) /
((cl->mlist.map_h * cl->mlist.scale) - 20)) + 1;
- y = cl->wlist.y_size - (cl->mlist.map_h * cl->mlist.scale) + 10;
+ y = cl->wlist.y_size - (cl->mlist.map_h * cl->mlist.scale) - 10;
while (y < (int16_t)cl->wlist.y_size - 10)
{
cl->tnum[10].tex_y = (y * y_ratio) >> 16;
@@ -54,8 +54,8 @@ static void
+ 10 + ((28 * cl->mlist.scale))))
{
cl->tnum[10].tex_x = (x * x_ratio) >> 16;
- if (cl->tnum[10].ptr[cl->tnum[10].tex_x * 4 + 4 *
- cl->tnum[10].img_h * cl->tnum[10].tex_y])
+ /* if (cl->tnum[10].ptr[cl->tnum[10].tex_x * 4 + 4 * */
+ /* cl->tnum[10].img_h * cl->tnum[10].tex_y]) */
ft_draw_tnum(cl->tnum[10], y, x, cl);
x++;
}