1 #ifndef INCLUDED_JUMPNRUN_ENEMIES_H
2 #define INCLUDED_JUMPNRUN_ENEMIES_H
4 #include "../ui/sprite.h"
5 #include "../util/rectangle.h"
10 struct jumpnrun_game_state
;
11 struct jumpnrun_level
;
12 struct jumpnrun_tile_range
;
14 struct jumpnrun_enemy
;
16 typedef struct jumpnrun_enemy_type
{
17 uint8_t animation_ticks_per_frame
;
18 uint8_t animation_length
;
19 badge_sprite
const *animation_frames
;
24 void (*collision_tiles
)(struct jumpnrun_enemy
*self
,
25 vec2d
*desired_position
,
26 struct jumpnrun_level
*lv
,
27 struct jumpnrun_tile_range
const *visible_tiles
);
28 void (*collision_player
)(struct jumpnrun_enemy
*self
,
29 struct jumpnrun_game_state
*state
,
30 vec2d
*player_inertia_mod
);
31 void (*collision_shots
)(struct jumpnrun_enemy
*self
,
32 struct jumpnrun_game_state
*state
);
34 void (*move_tick
)(struct jumpnrun_enemy
*self
,
35 struct jumpnrun_game_state
*state
,
36 struct jumpnrun_level
*lv
,
37 struct jumpnrun_tile_range
const *visible_tiles
,
38 vec2d
*player_inertia_mod
);
39 } jumpnrun_enemy_type
;
41 typedef struct jumpnrun_enemy
{
42 jumpnrun_moveable base
;
45 jumpnrun_enemy_type
const *type
;
49 // Do not collide with JUMPNRUN_MOVEABLE_* flags
50 JUMPNRUN_ENEMY_SPAWNED
= 128,
51 JUMPNRUN_ENEMY_UNAVAILABLE
= 64,
52 JUMPNRUN_ENEMY_MOVING
= 32,
53 JUMPNRUN_ENEMY_EVENT_TRIGGER1
= 16
56 static inline rectangle
const *enemy_hitbox(jumpnrun_enemy
const *enemy
) { return &enemy
->base
.hitbox
; }
57 void jumpnrun_enemy_despawn(jumpnrun_enemy
*self
);
58 void jumpnrun_enemy_reset (jumpnrun_enemy
*self
);
61 JUMPNRUN_ENEMY_TYPE_CAT
,
62 JUMPNRUN_ENEMY_TYPE_MUSHROOM
,
63 JUMPNRUN_ENEMY_TYPE_BUNNY
,
64 JUMPNRUN_ENEMY_TYPE_SNAKE
,
65 JUMPNRUN_ENEMY_TYPE_SPIRAL
,
66 JUMPNRUN_ENEMY_TYPE_ROTOR
,
67 JUMPNRUN_ENEMY_TYPE_DOG
,
68 JUMPNRUN_ENEMY_TYPE_GIRAFFE
,
69 JUMPNRUN_ENEMY_TYPE_BIRD
,
70 JUMPNRUN_ENEMY_TYPE_BIRD_STRAIGHT
,
71 JUMPNRUN_ENEMY_TYPE_BIRD_DIP
,
73 JUMPNRUN_ENEMY_TYPE_COUNT
76 extern jumpnrun_enemy_type
const jumpnrun_enemy_type_data
[JUMPNRUN_ENEMY_TYPE_COUNT
];
78 void jumpnrun_process_enemy(jumpnrun_enemy
*self
,
79 badge_framebuffer
*fb
,
80 struct jumpnrun_game_state
*state
,
81 struct jumpnrun_level
*lv
,
82 struct jumpnrun_tile_range
const *visible_tiles
,
83 vec2d
*player_inertia_mod
);