-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathshot_gun.c
82 lines (77 loc) · 2.83 KB
/
shot_gun.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* shot_gun.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: vvinogra <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/03/11 19:27:56 by vvinogra #+# #+# */
/* Updated: 2018/03/20 18:16:30 by vvinogra ### ########.fr */
/* */
/* ************************************************************************** */
#include "wolf.h"
void anim_shotgun_help(t_wolf *wolf)
{
if (wolf->fr >= 15)
mlx_put_image_to_window(wolf->mlx, wolf->win,
wolf->shotgun_two->image, (WIN_WIDTH - 400) / 2, WIN_HEIGHT - 400);
else if (wolf->fr >= 12 && wolf->fr <= 14)
mlx_put_image_to_window(wolf->mlx, wolf->win,
wolf->shotgun_three->image, (WIN_WIDTH - 400) / 2, WIN_HEIGHT - 400);
else if (wolf->fr >= 10 && wolf->fr <= 11)
mlx_put_image_to_window(wolf->mlx, wolf->win,
wolf->shotgun_four->image, (WIN_WIDTH - 400) / 2, WIN_HEIGHT - 400);
else if (wolf->fr >= 7 && wolf->fr <= 9)
mlx_put_image_to_window(wolf->mlx, wolf->win,
wolf->shotgun_five->image, (WIN_WIDTH - 400) / 2, WIN_HEIGHT - 400);
else if (wolf->fr >= 5 && wolf->fr <= 7)
mlx_put_image_to_window(wolf->mlx, wolf->win,
wolf->shotgun_four->image, (WIN_WIDTH - 400) / 2, WIN_HEIGHT - 400);
else if (wolf->fr >= 1 && wolf->fr <= 4)
mlx_put_image_to_window(wolf->mlx, wolf->win,
wolf->shotgun_three->image, (WIN_WIDTH - 400) / 2, WIN_HEIGHT - 400);
wolf->fr--;
if (wolf->fr == 1)
{
wolf->fr = 17;
wolf->shoot = 0;
}
}
void anim_shotgun(t_wolf *wolf)
{
if (wolf->shoot == 0)
{
mlx_put_image_to_window(wolf->mlx,
wolf->win, wolf->shotgun_one->image,
(WIN_WIDTH - 400) / 2, WIN_HEIGHT - 400);
}
else if (wolf->shoot == 1)
{
if (wolf->fr == 17)
Mix_PlayChannel(0, wolf->shoot_sound, 0);
anim_shotgun_help(wolf);
}
}
void aim_draw(t_wolf *wolf)
{
int x;
int y;
x = (WIN_WIDTH / 2) - 20;
y = WIN_HEIGHT / 2;
while (x <= (WIN_WIDTH / 2) + 20)
{
wolf->ret_im->pic[4 * (WIN_WIDTH * y + x)] = 0;
wolf->ret_im->pic[4 * (WIN_WIDTH * y + x) + 1] = 0;
wolf->ret_im->pic[4 * (WIN_WIDTH * y + x) + 2] = (unsigned char)255;
x++;
}
y = (WIN_HEIGHT / 2) - 20;
x = WIN_WIDTH / 2;
while (y <= (WIN_HEIGHT / 2) + 20)
{
wolf->ret_im->pic[4 * (WIN_WIDTH * y + x)] = 0;
wolf->ret_im->pic[4 * (WIN_WIDTH * y + x) + 1] = 0;
wolf->ret_im->pic[4 * (WIN_WIDTH * y + x) + 2] = (unsigned char)255;
y++;
}
}