Schussphysik: Schwung des Spielers mit einrechnen, Schüsse auf LCD sichtbarer.
[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 };
55
56 static inline rectangle const *enemy_box (jumpnrun_enemy const *enemy) { return &enemy->base.current_box ; }
57 static inline vec2d enemy_position (jumpnrun_enemy const *enemy) { return enemy->base.current_box.pos; }
58 static inline rectangle enemy_hitbox (jumpnrun_enemy const *enemy) { rectangle r = enemy->type->hitbox; rectangle_move_rel(&r, enemy_position(enemy)); return r; }
59 static inline badge_sprite const *enemy_sprite (jumpnrun_enemy const *enemy) { return &enemy->type->animation_frames[enemy->base.anim_frame]; }
60
61 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)); }
62 static inline uint8_t enemy_render_flags(jumpnrun_enemy const *enemy) { return enemy_facing_right(enemy) ? BADGE_BLT_MIRRORED : 0; }
63
64 enum {
65 JUMPNRUN_ENEMY_TYPE_CAT,
66 JUMPNRUN_ENEMY_TYPE_MUSHROOM,
67 JUMPNRUN_ENEMY_TYPE_BUNNY,
68 JUMPNRUN_ENEMY_TYPE_SNAKE,
69 JUMPNRUN_ENEMY_TYPE_SPIRAL,
70 JUMPNRUN_ENEMY_TYPE_ROTOR,
71 JUMPNRUN_ENEMY_TYPE_DOG,
72 JUMPNRUN_ENEMY_TYPE_GIRAFFE,
73 JUMPNRUN_ENEMY_TYPE_BIRD,
74
75 JUMPNRUN_ENEMY_TYPE_COUNT
76 };
77
78 extern jumpnrun_enemy_type const jumpnrun_enemy_type_data[JUMPNRUN_ENEMY_TYPE_COUNT];
79
80 void jumpnrun_process_enemy(jumpnrun_enemy *self,
81 badge_framebuffer *fb,
82 struct jumpnrun_game_state *state,
83 struct jumpnrun_level *lv,
84 struct jumpnrun_tile_range const *visible_tiles,
85 vec2d *player_inertia_mod);
86 #endif
This page took 0.057238 seconds and 5 git commands to generate.