c7dfa7e4e4368691ed5bebb3ea4fd68cb0128e7b
[hackover2013-badge-firmware.git] / badge / jumpnrun / enemies.h
1 #ifndef INCLUDED_JUMPNRUN_ENEMIES_H
2 #define INCLUDED_JUMPNRUN_ENEMIES_H
3
4 #include "../ui/sprite.h"
5 #include "../util/rectangle.h"
6
7 #include "moveable.h"
8 #include "tiles.h"
9
10 struct jumpnrun_game_state;
11 struct jumpnrun_level;
12 struct jumpnrun_tile_range;
13
14 struct jumpnrun_enemy;
15
16 typedef struct jumpnrun_enemy_type {
17 unsigned animation_ticks_per_frame;
18 size_t animation_length;
19 badge_sprite const *animation_frames;
20
21 rectangle hitbox;
22 vec2d spawn_inertia;
23
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);
33
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;
40
41 typedef struct jumpnrun_enemy {
42 jumpnrun_moveable base;
43 vec2d spawn_pos;
44
45 jumpnrun_enemy_type const *type;
46 } jumpnrun_enemy;
47
48 enum {
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
54 };
55
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);
59
60 enum {
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,
72
73 JUMPNRUN_ENEMY_TYPE_COUNT
74 };
75
76 extern jumpnrun_enemy_type const jumpnrun_enemy_type_data[JUMPNRUN_ENEMY_TYPE_COUNT];
77
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);
84 #endif
This page took 0.042712 seconds and 3 git commands to generate.