Skip to content

Commit 648c955

Browse files
committed
improved the animation of collecibles
1 parent 3e72b10 commit 648c955

12 files changed

+1801
-921
lines changed

bonus/ft_collectible_animation.c

Lines changed: 55 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
/* By: amait-ou <[email protected]> +#+ +:+ +#+ */
77
/* +#+#+#+#+#+ +#+ */
88
/* Created: 2023/02/07 17:14:47 by amait-ou #+# #+# */
9-
/* Updated: 2023/02/08 09:36:46 by amait-ou ### ########.fr */
9+
/* Updated: 2023/02/08 11:00:42 by amait-ou ### ########.fr */
1010
/* */
1111
/* ************************************************************************** */
1212

@@ -31,9 +31,36 @@ void ft_textures4(t_game *game)
3131
game->tex.co4 = mlx_xpm_file_to_image(
3232
game->mlx.mlx,
3333
"./textures/collectible_4.xpm", &x, &y);
34+
game->tex.co5 = mlx_xpm_file_to_image(
35+
game->mlx.mlx,
36+
"./textures/collectible_5.xpm", &x, &y);
3437
}
3538

36-
void ft_enemy_animation(t_game *game, int j, int i)
39+
void ft_textures5(t_game *game)
40+
{
41+
int x;
42+
int y;
43+
44+
x = game->img.w * 50;
45+
y = game->img.h * 50;
46+
game->tex.co6 = mlx_xpm_file_to_image(
47+
game->mlx.mlx,
48+
"./textures/collectible_6.xpm", &x, &y);
49+
game->tex.co6 = mlx_xpm_file_to_image(
50+
game->mlx.mlx,
51+
"./textures/collectible_6.xpm", &x, &y);
52+
game->tex.co7 = mlx_xpm_file_to_image(
53+
game->mlx.mlx,
54+
"./textures/collectible_7.xpm", &x, &y);
55+
game->tex.co8 = mlx_xpm_file_to_image(
56+
game->mlx.mlx,
57+
"./textures/collectible_8.xpm", &x, &y);
58+
game->tex.co9 = mlx_xpm_file_to_image(
59+
game->mlx.mlx,
60+
"./textures/collectible_9.xpm", &x, &y);
61+
}
62+
63+
void ft_enemy_animation_1(t_game *game, int j, int i)
3764
{
3865
if (game->col.c == 1)
3966
{
@@ -57,10 +84,34 @@ void ft_enemy_animation(t_game *game, int j, int i)
5784
}
5885
}
5986

87+
void ft_enemy_animation_2(t_game *game, int j, int i)
88+
{
89+
if (game->col.c == 21)
90+
{
91+
ft_texture_helper(game, game->tex.bgd, j, i);
92+
ft_texture_helper(game, game->tex.co5, j, i);
93+
}
94+
if (game->col.c == 26)
95+
{
96+
ft_texture_helper(game, game->tex.bgd, j, i);
97+
ft_texture_helper(game, game->tex.co6, j, i);
98+
}
99+
if (game->col.c == 31)
100+
{
101+
ft_texture_helper(game, game->tex.bgd, j, i);
102+
ft_texture_helper(game, game->tex.co7, j, i);
103+
}
104+
if (game->col.c == 36)
105+
{
106+
ft_texture_helper(game, game->tex.bgd, j, i);
107+
ft_texture_helper(game, game->tex.co8, j, i);
108+
}
109+
}
110+
60111
int ft_collectible_animation(t_game *game)
61112
{
62-
if (game->col.c == 16)
63-
game->col.c -= 16;
113+
if (game->col.c == 36)
114+
game->col.c -= 36;
64115
game->col.c++;
65116
return (1);
66117
}

bonus/ft_game_render_bonus.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
/* By: amait-ou <[email protected]> +#+ +:+ +#+ */
77
/* +#+#+#+#+#+ +#+ */
88
/* Created: 2023/01/30 01:33:55 by amait-ou #+# #+# */
9-
/* Updated: 2023/02/07 17:55:42 by amait-ou ### ########.fr */
9+
/* Updated: 2023/02/08 10:58:04 by amait-ou ### ########.fr */
1010
/* */
1111
/* ************************************************************************** */
1212

@@ -21,6 +21,7 @@ void ft_game_render(t_game *game)
2121
ft_textures1(game);
2222
ft_textures2(game);
2323
ft_textures4(game);
24+
ft_textures5(game);
2425
while (i < game->len)
2526
{
2627
j = 0;

bonus/ft_put_textures_bonus.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
/* By: amait-ou <[email protected]> +#+ +:+ +#+ */
77
/* +#+#+#+#+#+ +#+ */
88
/* Created: 2023/01/22 17:16:59 by amait-ou #+# #+# */
9-
/* Updated: 2023/02/08 09:38:19 by amait-ou ### ########.fr */
9+
/* Updated: 2023/02/08 11:00:51 by amait-ou ### ########.fr */
1010
/* */
1111
/* ************************************************************************** */
1212

@@ -89,7 +89,10 @@ void ft_put_textures(t_game *game, int i, int j)
8989
if (game->map[i][j] == 'E')
9090
ft_texture_helper(game, game->tex.ext, j, i);
9191
if (game->map[i][j] == 'C')
92-
ft_enemy_animation(game, j, i);
92+
{
93+
ft_enemy_animation_1(game, j, i);
94+
ft_enemy_animation_2(game, j, i);
95+
}
9396
if (game->map[i][j] == 'M')
9497
ft_texture_helper(game, game->tex.ene, j, i);
9598
++j;

bonus/so_long_bonus.h

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
/* By: amait-ou <[email protected]> +#+ +:+ +#+ */
77
/* +#+#+#+#+#+ +#+ */
88
/* Created: 2023/01/16 10:38:07 by amait-ou #+# #+# */
9-
/* Updated: 2023/02/08 09:37:34 by amait-ou ### ########.fr */
9+
/* Updated: 2023/02/08 11:01:05 by amait-ou ### ########.fr */
1010
/* */
1111
/* ************************************************************************** */
1212

@@ -41,6 +41,11 @@ typedef struct s_textures
4141
void *co2;
4242
void *co3;
4343
void *co4;
44+
void *co5;
45+
void *co6;
46+
void *co7;
47+
void *co8;
48+
void *co9;
4449
void *wal;
4550
void *pl1;
4651
void *pl2;
@@ -135,6 +140,7 @@ void ft_textures2(t_game *game);
135140
void ft_texture_helper(t_game *game, void *img, int j, int i);
136141
void ft_textures3(t_game *game, int j, int i);
137142
void ft_textures4(t_game *game);
143+
void ft_textures5(t_game *game);
138144
void ft_put_textures(t_game *game, int i, int j);
139145
void ft_player_coordonates(t_game *game, char c);
140146
void ft_player_editer(t_game *game, int y, int x, char c);
@@ -160,7 +166,8 @@ void ft_game_banner(void);
160166

161167
// Collectible Animation
162168
int ft_collectible_animation(t_game *game);
163-
void ft_enemy_animation(t_game *game, int j, int i);
169+
void ft_enemy_animation_1(t_game *game, int j, int i);
170+
void ft_enemy_animation_2(t_game *game, int j, int i);
164171

165172
// MLx Hook
166173
int ft_both(t_game *game);

0 commit comments

Comments
 (0)