aboutsummaryrefslogtreecommitdiffstats
path: root/src/ft_draw_handweap.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ft_draw_handweap.c')
-rw-r--r--src/ft_draw_handweap.c34
1 files changed, 32 insertions, 2 deletions
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);