Skip to content

Commit cd2d1c6

Browse files
committed
Added animation + fix
1 parent 8397636 commit cd2d1c6

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

includes/enemy.h

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,18 +42,30 @@ typedef struct s_ray_data
4242
int map_y;
4343
} t_ray_data;
4444

45+
#define NUM_ENEMY_FRAMES 2
46+
#define ENEMY_ANIM_SPEED 200 // milliseconds between frames
47+
48+
/* Update your t_enemy structure */
4549
typedef struct s_enemy
4650
{
4751
t_vector pos;
4852
t_vector dir;
4953
int health;
5054
bool alive;
5155
double dist_to_player;
52-
t_texture *texture;
56+
t_texture *texture; /* Keep original texture pointer */
5357
double detection_radius;
5458
double last_attack;
59+
60+
/* Animation fields */
61+
int current_frame; /* Current animation frame */
62+
double last_frame_change; /* When the last frame change occurred */
5563
} t_enemy;
5664

65+
/* Add these function prototypes at the end of your enemy.h file */
66+
void load_enemy_texture(t_game *game, t_enemy *enemy, int frame);
67+
void update_enemy_animation(t_enemy *enemy, t_game *game);
68+
void update_enemy_animations(t_game *game);
5769
typedef struct s_draw_params
5870
{
5971
t_game *game;
@@ -136,5 +148,6 @@ void adjust_angle_and_fov(double *angle, double *effective_fov,
136148
int calculate_sprite_height(double dist);
137149
void draw_enemy(t_game *game, t_enemy_list *current, double fov);
138150
void check_and_draw_enemy(t_game *g, t_enemy_list *crnt, double fov);
151+
bool should_render_enemy(t_game *game, t_enemy *enemy);
139152

140153
#endif

0 commit comments

Comments
 (0)