Sprites in Repo geworfen (damit nichts verlorengeht)
[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 vec2d extent;
22 rectangle hitbox;
23 vec2d spawn_inertia;
24
25 void (*collision_tiles)(struct jumpnrun_enemy *self,
26 vec2d *desired_position,
27 struct jumpnrun_level *lv,
28 struct jumpnrun_tile_range const *visible_tiles);
29 void (*collision_player)(struct jumpnrun_enemy *self,
30 struct jumpnrun_game_state *state,
31 vec2d *player_inertia_mod);
32 void (*collision_shots)(struct jumpnrun_enemy *self,
33 struct jumpnrun_game_state *state);
34
35 void (*move_tick)(struct jumpnrun_enemy *self,
36 struct jumpnrun_game_state *state,
37 struct jumpnrun_level *lv,
38 struct jumpnrun_tile_range const *visible_tiles,
39 vec2d *player_inertia_mod);
40 } jumpnrun_enemy_type;
41
42 typedef struct jumpnrun_enemy {
43 jumpnrun_moveable base;
44 vec2d spawn_pos;
45 unsigned flags;
46
47 jumpnrun_enemy_type const *type;
48 } jumpnrun_enemy;
49
50 enum {
51 JUMPNRUN_ENEMY_SPAWNED = 1,
52 JUMPNRUN_ENEMY_UNAVAILABLE = 2,
53 JUMPNRUN_ENEMY_FACING_RIGHT = 4,
54 JUMPNRUN_ENEMY_EVENT_TRIGGER1 = 128
55 };
56
57 static inline rectangle const *enemy_box (jumpnrun_enemy const *enemy) { return &enemy->base.current_box ; }
58 static inline vec2d enemy_position (jumpnrun_enemy const *enemy) { return enemy->base.current_box.pos; }
59 static inline rectangle enemy_hitbox (jumpnrun_enemy const *enemy) { rectangle r = enemy->type->hitbox; rectangle_move_rel(&r, enemy_position(enemy)); return r; }
60 static inline badge_sprite const *enemy_sprite (jumpnrun_enemy const *enemy) { return &enemy->type->animation_frames[enemy->base.anim_frame]; }
61
62 static inline bool enemy_facing_right(jumpnrun_enemy const *enemy) { return (enemy->flags & JUMPNRUN_ENEMY_FACING_RIGHT) || fixed_point_gt(enemy->base.inertia.x, FIXED_INT(0)); }
63 static inline uint8_t enemy_render_flags(jumpnrun_enemy const *enemy) { return enemy_facing_right(enemy) ? BADGE_BLT_MIRRORED : 0; }
64
65 enum {
66 JUMPNRUN_ENEMY_TYPE_CAT,
67 JUMPNRUN_ENEMY_TYPE_MUSHROOM,
68 JUMPNRUN_ENEMY_TYPE_BUNNY,
69 JUMPNRUN_ENEMY_TYPE_SNAKE,
70 JUMPNRUN_ENEMY_TYPE_SPIRAL,
71 JUMPNRUN_ENEMY_TYPE_ROTOR,
72 JUMPNRUN_ENEMY_TYPE_DOG,
73 JUMPNRUN_ENEMY_TYPE_GIRAFFE,
74 JUMPNRUN_ENEMY_TYPE_BIRD,
75 JUMPNRUN_ENEMY_TYPE_BIRD_STRAIGHT,
76 JUMPNRUN_ENEMY_TYPE_BIRD_DIP,
77
78 JUMPNRUN_ENEMY_TYPE_COUNT
79 };
80
81 extern jumpnrun_enemy_type const jumpnrun_enemy_type_data[JUMPNRUN_ENEMY_TYPE_COUNT];
82
83 void jumpnrun_process_enemy(jumpnrun_enemy *self,
84 badge_framebuffer *fb,
85 struct jumpnrun_game_state *state,
86 struct jumpnrun_level *lv,
87 struct jumpnrun_tile_range const *visible_tiles,
88 vec2d *player_inertia_mod);
89 #endif
This page took 0.057501 seconds and 5 git commands to generate.