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,
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;
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;
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.
void squish_me(Player* player);
/** set image of the badguy */
void set_sprite(Sprite* left, Sprite* right,
- int animlength = 1, float animspeed = 1);
+ int animlength = 1, float animspeed = 1);
};
#endif /*SUPERTUX_BADGUY_H*/
#define FPS (1000 / 25)
+enum Direction { LEFT = 0, RIGHT = 1 };
+
/* Direction (keyboard/joystick) states: */
#define UP 0
#define KILL 0
#define SHRINK 1
-/* Directions: */
-
-#define LEFT 0
-#define RIGHT 1
-
/* Sizes: */
#define SMALL 0
if (*i == '0' || *i == '1' || *i == '2')
{
badguy_data.push_back(BadGuyData(static_cast<BadGuyKind>(*i-'0'),
- x*32, y*32));
+ x*32, y*32, false));
*i = 0;
}
else
/* definitions to aid development */
-
/* definitions that affect gameplay */
#define KEY_CURSOR_SPEED 32
#define KEY_CURSOR_FASTSPEED 64
/* Hurt player if he touches a badguy */
if (!pbad_c->dying && !dying &&
!safe_timer.started() &&
- pbad_c->mode != HELD)
+ pbad_c->mode != BadGuy::HELD)
{
- if (pbad_c->mode == FLAT && input.fire == DOWN)
+ if (pbad_c->mode == BadGuy::FLAT && input.fire == DOWN)
{
- pbad_c->mode = HELD;
+ pbad_c->mode = BadGuy::HELD;
pbad_c->base.y-=8;
}
- else if (pbad_c->mode == FLAT)
+ else if (pbad_c->mode == BadGuy::FLAT)
{
// Don't get hurt if we're kicking a flat badguy!
}
- else if (pbad_c->mode == KICK)
+ else if (pbad_c->mode == BadGuy::KICK)
{
/* Hurt if you get hit by kicked laptop: */
if (!invincible_timer.started())
int size;
bool duck;
DyingType dying;
- int dir;
+
+ Direction dir;
+
bool jumping;
int frame_;
int frame_main;
#define GROWUP_SPEED 1.0f
void
-Bullet::init(float x, float y, float xm, int dir)
+Bullet::init(float x, float y, float xm, Direction dir)
{
base.width = 4;
base.height = 4;
}
void
-Upgrade::init(float x_, float y_, int dir_, UpgradeKind kind_)
+Upgrade::init(float x_, float y_, Direction dir_, UpgradeKind kind_)
{
kind = kind_;
dir = dir_;
{
public:
UpgradeKind kind;
- int dir;
+ Direction dir;
base_type base;
base_type old_base;
Physic physic;
- void init(float x, float y, int dir, UpgradeKind kind);
+ void init(float x, float y, Direction dir, UpgradeKind kind);
void action(double frame_ratio);
void draw();
void collision(void* p_c_object, int c_object);
base_type base;
base_type old_base;
- void init(float x, float y, float xm, int dir);
+ void init(float x, float y, float xm, Direction dir);
void action(double frame_ratio);
void draw();
void collision(int c_object);
}
void
-World::add_upgrade(float x, float y, int dir, UpgradeKind kind)
+World::add_upgrade(float x, float y, Direction dir, UpgradeKind kind)
{
Upgrade new_upgrade;
new_upgrade.init(x,y,dir,kind);
}
void
-World::add_bullet(float x, float y, float xm, int dir)
+World::add_bullet(float x, float y, float xm, Direction dir)
{
Bullet new_bullet;
new_bullet.init(x,y,xm,dir);
/* Empty a box: */
void
-World::tryemptybox(float x, float y, int col_side)
+World::tryemptybox(float x, float y, Direction col_side)
{
Tile* tile = gettile(x,y);
if (!tile->fullbox)
void add_broken_brick_piece(Tile* tile, float x, float y, float xm, float ym);
void add_bouncy_brick(float x, float y);
void add_bad_guy(float x, float y, BadGuyKind kind);
- void add_upgrade(float x, float y, int dir, UpgradeKind kind);
- void add_bullet(float x, float y, float xm, int dir);
+ void add_upgrade(float x, float y, Direction dir, UpgradeKind kind);
+ void add_bullet(float x, float y, float xm, Direction dir);
/** Try to grab the coin at the given coordinates */
void trygrabdistro(float x, float y, int bounciness);
void trybreakbrick(float x, float y, bool small);
/** Try to get the content out of a bonus box, thus emptying it */
- void tryemptybox(float x, float y, int col_side);
+ void tryemptybox(float x, float y, Direction col_side);
/** Try to bumb a badguy that might we walking above Tux, thus shaking
the tile which the badguy is walking on an killing him this way */