[Super-tux-commit] supertux/src badguy.h,1.28,1.29 defines.h,1.18,1.19 level.cpp,1.41,1.42 leveledit
Brought to you by:
wkendrick
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9421 Modified Files: badguy.h defines.h level.cpp leveleditor.cpp player.cpp player.h special.cpp special.h world.cpp world.h Log Message: - turned LEFT/RIGHT defines into enum, turned BadGuyModes into enum Index: world.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/world.h,v retrieving revision 1.25 retrieving revision 1.26 diff -u -d -r1.25 -r1.26 --- world.h 20 Apr 2004 11:09:34 -0000 1.25 +++ world.h 20 Apr 2004 19:55:23 -0000 1.26 @@ -87,8 +87,8 @@ 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); @@ -97,7 +97,7 @@ 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 */ Index: defines.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/defines.h,v retrieving revision 1.18 retrieving revision 1.19 diff -u -d -r1.18 -r1.19 --- defines.h 20 Apr 2004 17:31:00 -0000 1.18 +++ defines.h 20 Apr 2004 19:55:02 -0000 1.19 @@ -32,6 +32,8 @@ #define FPS (1000 / 25) +enum Direction { LEFT = 0, RIGHT = 1 }; + /* Direction (keyboard/joystick) states: */ #define UP 0 @@ -51,11 +53,6 @@ #define KILL 0 #define SHRINK 1 -/* Directions: */ - -#define LEFT 0 -#define RIGHT 1 - /* Sizes: */ #define SMALL 0 Index: badguy.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/badguy.h,v retrieving revision 1.28 retrieving revision 1.29 diff -u -d -r1.28 -r1.29 --- badguy.h 20 Apr 2004 18:39:18 -0000 1.28 +++ badguy.h 20 Apr 2004 19:55:02 -0000 1.29 @@ -36,27 +36,6 @@ 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 +62,13 @@ 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 +77,38 @@ 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; @@ -124,7 +130,7 @@ 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. @@ -167,7 +173,7 @@ 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*/ Index: player.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/player.h,v retrieving revision 1.31 retrieving revision 1.32 diff -u -d -r1.31 -r1.32 --- player.h 20 Apr 2004 16:26:06 -0000 1.31 +++ player.h 20 Apr 2004 19:55:10 -0000 1.32 @@ -110,7 +110,9 @@ int size; bool duck; DyingType dying; - int dir; + + Direction dir; + bool jumping; int frame_; int frame_main; Index: player.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/player.cpp,v retrieving revision 1.49 retrieving revision 1.50 diff -u -d -r1.49 -r1.50 --- player.cpp 20 Apr 2004 17:58:12 -0000 1.49 +++ player.cpp 20 Apr 2004 19:55:09 -0000 1.50 @@ -702,18 +702,18 @@ /* 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()) Index: level.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/level.cpp,v retrieving revision 1.41 retrieving revision 1.42 diff -u -d -r1.41 -r1.42 --- level.cpp 20 Apr 2004 11:37:10 -0000 1.41 +++ level.cpp 20 Apr 2004 19:55:02 -0000 1.42 @@ -416,7 +416,7 @@ 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 Index: special.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/special.cpp,v retrieving revision 1.22 retrieving revision 1.23 diff -u -d -r1.22 -r1.23 --- special.cpp 20 Apr 2004 11:37:10 -0000 1.22 +++ special.cpp 20 Apr 2004 19:55:10 -0000 1.23 @@ -40,7 +40,7 @@ #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; @@ -124,7 +124,7 @@ } 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_; Index: world.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/world.cpp,v retrieving revision 1.31 retrieving revision 1.32 diff -u -d -r1.31 -r1.32 --- world.cpp 20 Apr 2004 11:09:34 -0000 1.31 +++ world.cpp 20 Apr 2004 19:55:11 -0000 1.32 @@ -389,7 +389,7 @@ } 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); @@ -397,7 +397,7 @@ } 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); @@ -453,7 +453,7 @@ /* 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) Index: special.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/special.h,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -r1.15 -r1.16 --- special.h 20 Apr 2004 11:09:34 -0000 1.15 +++ special.h 20 Apr 2004 19:55:10 -0000 1.16 @@ -47,12 +47,12 @@ { 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); @@ -71,7 +71,7 @@ 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); Index: leveleditor.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/leveleditor.cpp,v retrieving revision 1.59 retrieving revision 1.60 diff -u -d -r1.59 -r1.60 --- leveleditor.cpp 20 Apr 2004 18:51:22 -0000 1.59 +++ leveleditor.cpp 20 Apr 2004 19:55:03 -0000 1.60 @@ -44,7 +44,6 @@ /* definitions to aid development */ - /* definitions that affect gameplay */ #define KEY_CURSOR_SPEED 32 #define KEY_CURSOR_FASTSPEED 64 |