Vorarbeit f. Schüsse/Würfe. Animation steht, TODO: Gegner darauf reagieren
[hackover2013-badge-firmware.git] / badge / jumpnrun / enemies.h
index ecb2b4e..9c08f68 100644 (file)
@@ -23,17 +23,17 @@ typedef struct jumpnrun_enemy_type {
   vec2d               spawn_inertia;
 
   void (*collision_tiles)(struct jumpnrun_enemy             *self,
-                         vec2d                             *desired_position,
-                         struct jumpnrun_level             *lv,
-                         struct jumpnrun_tile_range  const *visible_tiles);
+                          vec2d                             *desired_position,
+                          struct jumpnrun_level             *lv,
+                          struct jumpnrun_tile_range  const *visible_tiles);
   void (*collision_player)(struct jumpnrun_enemy      *self,
-                          struct jumpnrun_game_state *state,
-                          vec2d                      *player_inertia_mod);
+                           struct jumpnrun_game_state *state,
+                           vec2d                      *player_inertia_mod);
   void (*game_tick)(struct jumpnrun_enemy            *self,
-                   struct jumpnrun_game_state       *state,
+                    struct jumpnrun_game_state       *state,
                     struct jumpnrun_level            *lv,
                     struct jumpnrun_tile_range const *visible_tiles,
-                   vec2d                            *player_inertia_mod);
+                    vec2d                            *player_inertia_mod);
 } jumpnrun_enemy_type;
 
 typedef struct jumpnrun_enemy {
@@ -44,16 +44,19 @@ typedef struct jumpnrun_enemy {
   jumpnrun_enemy_type const *type;
 } jumpnrun_enemy;
 
+enum {
+  JUMPNRUN_ENEMY_SPAWNED      = 1,
+  JUMPNRUN_ENEMY_UNAVAILABLE  = 2,
+  JUMPNRUN_ENEMY_FACING_RIGHT = 4
+};
+
 static inline rectangle    const *enemy_box         (jumpnrun_enemy const *enemy) { return &enemy->base.current_box   ; }
 static inline vec2d               enemy_position    (jumpnrun_enemy const *enemy) { return enemy->base.current_box.pos; }
 static inline rectangle           enemy_hitbox      (jumpnrun_enemy const *enemy) { rectangle r = enemy->type->hitbox; rectangle_move_rel(&r, enemy_position(enemy)); return r; }
 static inline badge_sprite const *enemy_sprite      (jumpnrun_enemy const *enemy) { return &enemy->type->animation_frames[enemy->base.anim_frame]; }
-static inline uint8_t             enemy_render_flags(jumpnrun_enemy const *enemy) { return fixed_point_lt(enemy->base.inertia.x, FIXED_POINT(0, 0)) ? 0 : BADGE_BLT_MIRRORED; }
 
-enum {
-  JUMPNRUN_ENEMY_SPAWNED     = 1,
-  JUMPNRUN_ENEMY_UNAVAILABLE = 2
-};
+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)); }
+static inline uint8_t             enemy_render_flags(jumpnrun_enemy const *enemy) { return enemy_facing_right(enemy) ? BADGE_BLT_MIRRORED : 0; }
 
 enum {
   JUMPNRUN_ENEMY_TYPE_CAT,
@@ -61,6 +64,10 @@ enum {
   JUMPNRUN_ENEMY_TYPE_BUNNY,
   JUMPNRUN_ENEMY_TYPE_SNAKE,
   JUMPNRUN_ENEMY_TYPE_SPIRAL,
+  JUMPNRUN_ENEMY_TYPE_ROTOR,
+  JUMPNRUN_ENEMY_TYPE_DOG,
+  JUMPNRUN_ENEMY_TYPE_GIRAFFE,
+  JUMPNRUN_ENEMY_TYPE_BIRD,
 
   JUMPNRUN_ENEMY_TYPE_COUNT
 };
@@ -68,9 +75,9 @@ enum {
 extern jumpnrun_enemy_type const jumpnrun_enemy_type_data[JUMPNRUN_ENEMY_TYPE_COUNT];
 
 void jumpnrun_process_enemy(jumpnrun_enemy                   *self,
-                           badge_framebuffer                *fb,
-                           struct jumpnrun_game_state       *state,
-                           struct jumpnrun_level            *lv,
-                           struct jumpnrun_tile_range const *visible_tiles,
-                           vec2d                            *player_inertia_mod);
+                            badge_framebuffer                *fb,
+                            struct jumpnrun_game_state       *state,
+                            struct jumpnrun_level            *lv,
+                            struct jumpnrun_tile_range const *visible_tiles,
+                            vec2d                            *player_inertia_mod);
 #endif
This page took 0.034769 seconds and 4 git commands to generate.