- fixed bomb-dup bug (vector increases on add, and this changes I guess, so remove...
[supertux.git] / src / badguy.h
index 94b5444..29d5a19 100644 (file)
@@ -24,6 +24,7 @@
 #define SUPERTUX_BADGUY_H
 
 #include "SDL.h"
+#include "defines.h"
 #include "bitmask.h"
 #include "type.h"
 #include "timer.h"
@@ -36,27 +37,6 @@ extern Sprite* img_bsod_left;
 extern Sprite* img_bsod_right;
 extern Sprite* img_laptop_left;
 
-/* Enemy modes: */
-enum {
-    NORMAL=0,
-    FLAT,
-    KICK,
-    HELD,
-
-    MONEY_JUMP,
-
-    BOMB_TICKING,
-    BOMB_EXPLODE,
-
-    STALACTITE_SHAKING,
-    STALACTITE_FALL,
-
-    FISH_WAIT,
-
-    FLY_UP,
-    FLY_DOWN
-};
-
 /* Bad guy kinds: */
 enum BadGuyKind {
   BAD_BSOD,
@@ -83,12 +63,13 @@ struct BadGuyData
   BadGuyKind kind;
   int x;
   int y;
+  bool stay_on_platform;
 
-  BadGuyData(BadGuyKind kind_, int x_, int y_) 
-    : kind(kind_), x(x_), y(y_) {}
+  BadGuyData(BadGuyKind kind_, int x_, int y_, bool stay_on_platform_
+    : kind(kind_), x(x_), y(y_), stay_on_platform(stay_on_platform_) {}
 
   BadGuyData()
-    : kind(BAD_BSOD), x(0), y(0) {}
+    : kind(BAD_BSOD), x(0), y(0), stay_on_platform(false) {}
 };
 
 class Player;
@@ -97,12 +78,38 @@ class Player;
 class BadGuy
 {
 public:
-  DyingType dying;
-  base_type base;
+  /* Enemy modes: */
+  enum BadGuyMode {
+    NORMAL=0,
+    FLAT,
+    KICK,
+    HELD,
+
+    MONEY_JUMP,
+
+    BOMB_TICKING,
+    BOMB_EXPLODE,
+
+    STALACTITE_SHAKING,
+    STALACTITE_FALL,
+
+    FISH_WAIT,
+
+    FLY_UP,
+    FLY_DOWN
+  };
+public:
+  DyingType  dying;
+  base_type  base;
   BadGuyKind kind;
-  int mode;
+  BadGuyMode mode;
+
+  /** If true the enemy will stay on its current platform, ie. if he
+      reaches the edge he will turn around and walk into the other
+      direction, if false the enemy will jump or walk of the edge */
   bool stay_on_platform;
-  int dir;
+
+  Direction dir;
 
 private:
   bool seen;
@@ -114,17 +121,15 @@ private:
   Sprite*   sprite_right;
 
   int animation_offset;
-  size_t animation_length;
-  float animation_speed;
 
 public:
-  void init(float x, float y, BadGuyKind kind);
+  void init(float x, float y, BadGuyKind kind, bool stay_on_platform);
 
   void action(float frame_ratio);
   void draw();
 
   void collision(void* p_c_object, int c_object,
-          CollisionType type = COLLISION_NORMAL);
+                 CollisionType type = COLLISION_NORMAL);
 
   /** this functions tries to kill the badguy and lets him fall off the
    * screen. Some badguys like the flame might ignore this.
@@ -166,8 +171,7 @@ private:
   /** squish ourself, give player score and set dying to DYING_SQICHED */
   void squish_me(Player* player);
   /** set image of the badguy */
-  void set_sprite(Sprite* left, Sprite* right,
-        int animlength = 1, float animspeed = 1);
+  void set_sprite(Sprite* left, Sprite* right);
 };
 
 #endif /*SUPERTUX_BADGUY_H*/