super-tux-commit Mailing List for Super Tux (Page 93)
Brought to you by:
wkendrick
You can subscribe to this list here.
2004 |
Jan
|
Feb
|
Mar
(94) |
Apr
(500) |
May
(531) |
Jun
(196) |
Jul
(224) |
Aug
(193) |
Sep
(117) |
Oct
(115) |
Nov
(319) |
Dec
(97) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2005 |
Jan
(19) |
Feb
|
Mar
(105) |
Apr
(41) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2006 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(6) |
2007 |
Jan
(1) |
Feb
(2) |
Mar
|
Apr
(1) |
May
|
Jun
|
Jul
(2) |
Aug
(2) |
Sep
|
Oct
|
Nov
|
Dec
|
2008 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(1) |
Jun
(4) |
Jul
|
Aug
|
Sep
(7) |
Oct
(12) |
Nov
(26) |
Dec
(39) |
2009 |
Jan
(6) |
Feb
(15) |
Mar
(10) |
Apr
(25) |
May
(29) |
Jun
(21) |
Jul
(26) |
Aug
(8) |
Sep
(3) |
Oct
|
Nov
|
Dec
(10) |
2010 |
Jan
(5) |
Feb
(5) |
Mar
(2) |
Apr
|
May
(5) |
Jun
|
Jul
(1) |
Aug
(2) |
Sep
(2) |
Oct
(2) |
Nov
|
Dec
|
From: Ricardo C. <rm...@us...> - 2004-04-20 22:52:54
|
Update of /cvsroot/super-tux/supertux/data/levels/default In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13885/data/levels/default Removed Files: info info.png level1.stl level2.stl level3.stl Log Message: These levels are all in the world1 dir. --- level1.stl DELETED --- --- info DELETED --- --- level3.stl DELETED --- --- info.png DELETED --- --- level2.stl DELETED --- |
From: Ingo R. <gr...@us...> - 2004-04-20 20:11:47
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12572 Modified Files: badguy.cpp badguy.h level.cpp leveleditor.cpp world.cpp world.h Log Message: - added stay-on-platform into the level fileformat Index: world.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/world.h,v retrieving revision 1.26 retrieving revision 1.27 diff -u -d -r1.26 -r1.27 --- world.h 20 Apr 2004 19:55:23 -0000 1.26 +++ world.h 20 Apr 2004 20:10:53 -0000 1.27 @@ -86,7 +86,7 @@ void add_broken_brick(Tile* tile, float x, float y); 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_bad_guy(float x, float y, BadGuyKind kind, bool stay_on_platform = false); void add_upgrade(float x, float y, Direction dir, UpgradeKind kind); void add_bullet(float x, float y, float xm, Direction dir); Index: leveleditor.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/leveleditor.cpp,v retrieving revision 1.60 retrieving revision 1.61 diff -u -d -r1.60 -r1.61 --- leveleditor.cpp 20 Apr 2004 19:55:03 -0000 1.60 +++ leveleditor.cpp 20 Apr 2004 20:10:49 -0000 1.61 @@ -95,7 +95,7 @@ bad_guys.push_back(BadGuy()); BadGuy& new_bad_guy = bad_guys.back(); - new_bad_guy.init(x,y,kind); + new_bad_guy.init(x,y,kind, false /* stay_on_platform */); } void activate_bad_guys() Index: badguy.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/badguy.h,v retrieving revision 1.29 retrieving revision 1.30 diff -u -d -r1.29 -r1.30 --- badguy.h 20 Apr 2004 19:55:02 -0000 1.29 +++ badguy.h 20 Apr 2004 20:10:47 -0000 1.30 @@ -124,7 +124,7 @@ 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(); Index: badguy.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/badguy.cpp,v retrieving revision 1.39 retrieving revision 1.40 diff -u -d -r1.39 -r1.40 --- badguy.cpp 20 Apr 2004 18:39:17 -0000 1.39 +++ badguy.cpp 20 Apr 2004 20:10:26 -0000 1.40 @@ -144,7 +144,7 @@ } void -BadGuy::init(float x, float y, BadGuyKind kind_) +BadGuy::init(float x, float y, BadGuyKind kind_, bool stay_on_platform_) { base.x = x; base.y = y; @@ -153,7 +153,7 @@ base.xm = 0; base.ym = 0; - stay_on_platform = false; + stay_on_platform = stay_on_platform_; mode = NORMAL; dying = DYING_NOT; kind = kind_; Index: level.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/level.cpp,v retrieving revision 1.42 retrieving revision 1.43 diff -u -d -r1.42 -r1.43 --- level.cpp 20 Apr 2004 19:55:02 -0000 1.42 +++ level.cpp 20 Apr 2004 20:10:48 -0000 1.43 @@ -358,6 +358,7 @@ LispReader reader(lisp_cdr(data)); reader.read_int("x", &bg_data.x); reader.read_int("y", &bg_data.y); + reader.read_bool("stay-on-platform", &bg_data.stay_on_platform); badguy_data.push_back(bg_data); @@ -572,7 +573,9 @@ for(std::vector<BadGuyData>::iterator it = badguy_data.begin(); it != badguy_data.end(); ++it) - fprintf( fi,"(%s (x %d) (y %d))\n",badguykind_to_string((*it).kind).c_str(),(*it).x,(*it).y); + fprintf( fi,"(%s (x %d) (y %d) (stay-on-platform %s))\n", + badguykind_to_string((*it).kind).c_str(),(*it).x,(*it).y, + it->stay_on_platform ? "#t" : "#f"); fprintf( fi,")\n"); Index: world.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/world.cpp,v retrieving revision 1.32 retrieving revision 1.33 diff -u -d -r1.32 -r1.33 --- world.cpp 20 Apr 2004 19:55:11 -0000 1.32 +++ world.cpp 20 Apr 2004 20:10:52 -0000 1.33 @@ -97,7 +97,7 @@ i != level->badguy_data.end(); ++i) { - add_bad_guy(i->x, i->y, i->kind); + add_bad_guy(i->x, i->y, i->kind, i->stay_on_platform); } } @@ -380,12 +380,12 @@ } void -World::add_bad_guy(float x, float y, BadGuyKind kind) +World::add_bad_guy(float x, float y, BadGuyKind kind, bool stay_on_platform) { bad_guys.push_back(BadGuy()); BadGuy& new_bad_guy = bad_guys.back(); - new_bad_guy.init(x,y,kind); + new_bad_guy.init(x,y,kind, stay_on_platform); } void |
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 |
From: Ricardo C. <rm...@us...> - 2004-04-20 18:51:31
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28393/src Modified Files: leveleditor.cpp Log Message: When Esc was pressed the menu was not being shown in leveleditor (fixed). Index: leveleditor.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/leveleditor.cpp,v retrieving revision 1.58 retrieving revision 1.59 diff -u -d -r1.58 -r1.59 --- leveleditor.cpp 20 Apr 2004 14:30:03 -0000 1.58 +++ leveleditor.cpp 20 Apr 2004 18:51:22 -0000 1.59 @@ -815,6 +815,8 @@ key = event.key.keysym.sym; switch(key) { + case SDLK_ESCAPE: + Menu::set_current(leveleditor_menu); case SDLK_LEFT: if(fire == DOWN) cursor_x -= KEY_CURSOR_SPEED; |
From: Ricardo C. <rm...@us...> - 2004-04-20 18:47:12
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27309/src Modified Files: gameloop.cpp Log Message: Level test mode didn't quit properly when Esc was pressed (fixed) Index: gameloop.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/gameloop.cpp,v retrieving revision 1.88 retrieving revision 1.89 diff -u -d -r1.88 -r1.89 --- gameloop.cpp 20 Apr 2004 18:40:40 -0000 1.88 +++ gameloop.cpp 20 Apr 2004 18:46:57 -0000 1.89 @@ -493,9 +493,6 @@ frame_ratio -= 1.0f; } overlap = frame_ratio; - - if (exit_status != NONE) - return exit_status; } else { @@ -563,7 +560,7 @@ } } } - + halt_music(); world->get_level()->free_gfx(); |
From: Ricardo C. <rm...@us...> - 2004-04-20 18:40:49
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25989/src Modified Files: gameloop.cpp Log Message: Time is not stopped during menu display in gameloop (fix). Probably there is a prettier way to fix this ;) Index: gameloop.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/gameloop.cpp,v retrieving revision 1.87 retrieving revision 1.88 diff -u -d -r1.87 -r1.88 --- gameloop.cpp 20 Apr 2004 16:25:56 -0000 1.87 +++ gameloop.cpp 20 Apr 2004 18:40:40 -0000 1.88 @@ -170,7 +170,6 @@ else if (!Menu::current()) { Menu::set_current(game_menu); - st_pause_ticks_stop(); } } @@ -186,9 +185,12 @@ if (Menu::current()) { Menu::current()->event(event); + st_pause_ticks_start(); } else { + st_pause_ticks_stop(); + switch(event.type) { case SDL_QUIT: /* Quit event - quit: */ |
From: Ingo R. <gr...@us...> - 2004-04-20 18:39:31
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25678 Modified Files: badguy.cpp badguy.h physic.cpp Log Message: - added stay_on_platform flag for badguys - some code cleanup - tweaked iceblocx speed Index: badguy.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/badguy.h,v retrieving revision 1.27 retrieving revision 1.28 diff -u -d -r1.27 -r1.28 --- badguy.h 20 Apr 2004 11:09:33 -0000 1.27 +++ badguy.h 20 Apr 2004 18:39:18 -0000 1.28 @@ -101,6 +101,7 @@ base_type base; BadGuyKind kind; int mode; + bool stay_on_platform; int dir; private: Index: physic.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/physic.cpp,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- physic.cpp 20 Apr 2004 17:58:00 -0000 1.11 +++ physic.cpp 20 Apr 2004 18:39:18 -0000 1.12 @@ -46,7 +46,7 @@ void Physic::set_velocity_x(float nvx) { - vx = -nvx; + vx = nvx; } void @@ -58,8 +58,8 @@ void Physic::set_velocity(float nvx, float nvy) { - vx = nvx; - vy = -nvy; + vx = nvx; + vy = -nvy; } void Physic::inverse_velocity_x() Index: badguy.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/badguy.cpp,v retrieving revision 1.38 retrieving revision 1.39 diff -u -d -r1.38 -r1.39 --- badguy.cpp 20 Apr 2004 11:09:33 -0000 1.38 +++ badguy.cpp 20 Apr 2004 18:39:17 -0000 1.39 @@ -153,6 +153,7 @@ base.xm = 0; base.ym = 0; + stay_on_platform = false; mode = NORMAL; dying = DYING_NOT; kind = kind_; @@ -173,7 +174,7 @@ physic.set_velocity(-1.3, 0); set_sprite(img_mrbomb_left, img_mrbomb_right, 4); } else if (kind == BAD_LAPTOP) { - physic.set_velocity(-1.3, 0); + physic.set_velocity(-.8, 0); set_sprite(img_laptop_left, img_laptop_right, 4, 5); } else if(kind == BAD_MONEY) { set_sprite(img_jumpy_left_up, img_jumpy_left_up, 1); @@ -225,10 +226,11 @@ // jump when we're about to fall if (physic.get_velocity_y() == 0 && - !issolid(base.x+base.width/2, base.y + base.height)) { - physic.enable_gravity(true); - physic.set_velocity(physic.get_velocity_x(), BSODJUMP); - } + !issolid(base.x+base.width/2, base.y + base.height)) + { + physic.enable_gravity(true); + physic.set_velocity(physic.get_velocity_x(), BSODJUMP); + } // Handle dying timer: if (dying == DYING_SQUISHED && !timer.check()) @@ -290,7 +292,7 @@ mode=KICK; set_sprite(img_laptop_flat_left, img_laptop_flat_right, 1); - physic.set_velocity((dir == LEFT) ? -8 : 8, -8); + physic.set_velocity_x((dir == LEFT) ? -3.5 : 3.5); play_sound(sounds[SND_KICK],SOUND_CENTER_SPEAKER); } } @@ -318,7 +320,7 @@ { mode = NORMAL; set_sprite(img_laptop_left, img_laptop_right, 4, 5); - physic.set_velocity( (dir == LEFT) ? -1.3 : 1.3, 0); + physic.set_velocity( (dir == LEFT) ? -.8 : .8, 0); } } } @@ -378,10 +380,23 @@ if (physic.get_velocity_y() < 0) { base.y = int((base.y + base.height)/32) * 32 - base.height; - physic.set_velocity(physic.get_velocity_x(), 0); + physic.set_velocity_y(0); } // no gravity anymore please physic.enable_gravity(false); + + if (stay_on_platform && mode == NORMAL) + { + if (!issolid(base.x + ((dir == LEFT) ? 0 : base.width), + base.y + base.height)) + { + physic.set_velocity_x(-physic.get_velocity_x()); + if (dir == LEFT) + dir = RIGHT; + else + dir = LEFT; + } + } } } else @@ -421,7 +436,7 @@ // jump when on ground if(dying == DYING_NOT && issolid(base.x, base.y+32)) { - physic.set_velocity(physic.get_velocity_x(), JUMPV); + physic.set_velocity_y(JUMPV); physic.enable_gravity(true); mode = MONEY_JUMP; @@ -581,7 +596,7 @@ // jump when on ground if(dying == DYING_NOT && issolid(base.x, base.y+32)) { - physic.set_velocity(physic.get_velocity_x(), JUMPV); + physic.set_velocity_y(JUMPV); physic.enable_gravity(true); } else @@ -614,17 +629,17 @@ // go into flyup mode if none specified yet if(dying == DYING_NOT && mode == NORMAL) { mode = FLY_UP; - physic.set_velocity(physic.get_velocity_x(), FLYINGSPEED); + physic.set_velocity_y(FLYINGSPEED); timer.start(DIRCHANGETIME/2); } if(dying == DYING_NOT && !timer.check()) { if(mode == FLY_UP) { mode = FLY_DOWN; - physic.set_velocity(physic.get_velocity_x(), -FLYINGSPEED); + physic.set_velocity_y(-FLYINGSPEED); } else if(mode == FLY_DOWN) { mode = FLY_UP; - physic.set_velocity(physic.get_velocity_x(), FLYINGSPEED); + physic.set_velocity_y(FLYINGSPEED); } timer.start(DIRCHANGETIME); } @@ -657,7 +672,7 @@ if (physic.get_velocity_y() == 0 && !issolid(base.x+base.width/2, base.y + base.height)) { physic.enable_gravity(true); - physic.set_velocity(physic.get_velocity_x(), 2); + physic.set_velocity_y(2); } #endif @@ -826,7 +841,7 @@ void BadGuy::make_player_jump(Player* player) { - player->physic.set_velocity(player->physic.get_velocity_x(), 2); + player->physic.set_velocity_y(2); player->base.y = base.y - player->base.height - 2; } @@ -863,7 +878,7 @@ } else if(kind == BAD_BSOD) { squish_me(player); set_sprite(img_bsod_squished_left, img_bsod_squished_right, 1); - physic.set_velocity(0, physic.get_velocity_y()); + physic.set_velocity_x(0); return; } else if (kind == BAD_LAPTOP) { @@ -873,7 +888,7 @@ play_sound(sounds[SND_STOMP], SOUND_CENTER_SPEAKER); mode = FLAT; set_sprite(img_laptop_flat_left, img_laptop_flat_right, 1); - physic.set_velocity(0, physic.get_velocity_y()); + physic.set_velocity_x(0); timer.start(4000); } else if (mode == FLAT) { @@ -881,10 +896,10 @@ play_sound(sounds[SND_KICK], SOUND_CENTER_SPEAKER); if (player->base.x < base.x + (base.width/2)) { - physic.set_velocity(5, physic.get_velocity_y()); + physic.set_velocity_x(5); dir = RIGHT; } else { - physic.set_velocity(-5, physic.get_velocity_y()); + physic.set_velocity_x(-5); dir = LEFT; } @@ -938,7 +953,7 @@ set_sprite(img_bsod_falling_left, img_bsod_falling_right, 1); physic.enable_gravity(true); - physic.set_velocity(physic.get_velocity_x(), 0); + physic.set_velocity_y(0); /* Gain some points: */ if (kind == BAD_BSOD) @@ -1029,12 +1044,12 @@ // Hit from left side if (player->base.x < base.x) { - physic.set_velocity(5, physic.get_velocity_y()); + physic.set_velocity_x(5); dir = RIGHT; } // Hit from right side else { - physic.set_velocity(-5, physic.get_velocity_y()); + physic.set_velocity_x(-5); dir = LEFT; } |
From: Ingo R. <gr...@us...> - 2004-04-20 17:58:51
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17991 Modified Files: physic.cpp physic.h player.cpp Log Message: - stop tux if he ran into a block, no more accelerating while standing infront of a block Index: player.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/player.cpp,v retrieving revision 1.48 retrieving revision 1.49 diff -u -d -r1.48 -r1.49 --- player.cpp 20 Apr 2004 17:31:11 -0000 1.48 +++ player.cpp 20 Apr 2004 17:58:12 -0000 1.49 @@ -183,17 +183,27 @@ previous_base = base; physic.apply(frame_ratio, base.x, base.y); - if(dying == DYING_NOT) { + if(dying == DYING_NOT) + { + base_type target = base; + collision_swept_object_map(&old_base, &base); + + // Don't accelerate Tux if he is running against a wall + if (target.x != base.x) + { + physic.set_velocity_x(0); + } + // special exception for cases where we're stuck under tiles after // being ducked. In this case we drift out if(!duck && on_ground() && old_base.x == base.x && old_base.y == base.y - && collision_object_map(&base)) { - base.x += frame_ratio * WALK_SPEED * (dir ? 1 : -1); - previous_base = old_base = base; + && collision_object_map(&base)) { + base.x += frame_ratio * WALK_SPEED * (dir ? 1 : -1); + previous_base = old_base = base; } keep_in_bounds(); - } + } if (dying == DYING_NOT) { @@ -273,10 +283,10 @@ if (get_current_music() == HERRING_MUSIC && !invincible_timer.check()) { /* - no, we are no more invincible - or we were not in invincible mode - but are we in hurry ? - */ + no, we are no more invincible + or we were not in invincible mode + but are we in hurry ? + */ // FIXME: Move this to gamesession if (GameSession::current()->time_left.get_left() < TIME_WARNING) @@ -284,7 +294,7 @@ /* yes, we are in hurry stop the herring_song, prepare to play the correct fast level_song ! - */ + */ set_current_music(HURRYUP_MUSIC); } else Index: physic.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/physic.h,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- physic.h 20 Apr 2004 17:31:11 -0000 1.12 +++ physic.h 20 Apr 2004 17:58:00 -0000 1.13 @@ -51,6 +51,9 @@ */ void set_acceleration(float ax, float ay); + void set_acceleration_x(float ax); + void set_acceleration_y(float ay); + float get_acceleration_x(); float get_acceleration_y(); Index: physic.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/physic.cpp,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- physic.cpp 20 Apr 2004 17:31:11 -0000 1.10 +++ physic.cpp 20 Apr 2004 17:58:00 -0000 1.11 @@ -85,6 +85,18 @@ } void +Physic::set_acceleration_x(float nax) +{ + ax = nax; +} + +void +Physic::set_acceleration_y(float nay) +{ + ay = -nay; +} + +void Physic::set_acceleration(float nax, float nay) { ax = nax; |
From: Ingo R. <gr...@us...> - 2004-04-20 17:32:26
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12665 Modified Files: defines.h globals.cpp physic.cpp physic.h player.cpp Log Message: - switched gamespeed back to normal - added high-jump while running Index: physic.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/physic.h,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- physic.h 20 Apr 2004 11:09:34 -0000 1.11 +++ physic.h 20 Apr 2004 17:31:11 -0000 1.12 @@ -36,6 +36,9 @@ /** sets velocity to a fixed value */ void set_velocity(float vx, float vy); + void set_velocity_x(float vx); + void set_velocity_y(float vy); + /** velocities invertion */ void inverse_velocity_x(); void inverse_velocity_y(); Index: physic.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/physic.cpp,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- physic.cpp 20 Apr 2004 11:09:34 -0000 1.9 +++ physic.cpp 20 Apr 2004 17:31:11 -0000 1.10 @@ -44,6 +44,18 @@ } void +Physic::set_velocity_x(float nvx) +{ + vx = -nvx; +} + +void +Physic::set_velocity_y(float nvy) +{ + vy = -nvy; +} + +void Physic::set_velocity(float nvx, float nvy) { vx = nvx; Index: globals.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/globals.cpp,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -r1.16 -r1.17 --- globals.cpp 20 Apr 2004 16:50:18 -0000 1.16 +++ globals.cpp 20 Apr 2004 17:31:11 -0000 1.17 @@ -54,7 +54,7 @@ bool use_fullscreen; bool debug_mode; bool show_fps; -float game_speed = 1.2f; +float game_speed = 1.0f; int joystick_num = 0; char* level_startup_file = 0; Index: player.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/player.cpp,v retrieving revision 1.47 retrieving revision 1.48 diff -u -d -r1.47 -r1.48 --- player.cpp 20 Apr 2004 16:25:57 -0000 1.47 +++ player.cpp 20 Apr 2004 17:31:11 -0000 1.48 @@ -206,7 +206,7 @@ if(under_solid()) { // fall down - physic.set_velocity(physic.get_velocity_x(), 0); + physic.set_velocity_y(0); jumped_in_solid = true; } } @@ -216,7 +216,7 @@ if (physic.get_velocity_y() < 0) { base.y = (int)(((int)base.y / 32) * 32); - physic.set_velocity(physic.get_velocity_x(), 0); + physic.set_velocity_y(0); } physic.enable_gravity(false); @@ -410,7 +410,11 @@ if (on_ground()) { // jump - physic.set_velocity(physic.get_velocity_x(), 5.5); + if (physic.get_velocity_x() > MAX_WALK_XM) + physic.set_velocity_y(5.8); + else + physic.set_velocity_y(5.2); + --base.y; jumping = true; if (size == SMALL) @@ -423,7 +427,7 @@ { jumping = false; if(physic.get_velocity_y() > 0) { - physic.set_velocity(physic.get_velocity_x(), 0); + physic.set_velocity_y(0); } } } Index: defines.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/defines.h,v retrieving revision 1.17 retrieving revision 1.18 diff -u -d -r1.17 -r1.18 --- defines.h 20 Apr 2004 12:24:28 -0000 1.17 +++ defines.h 20 Apr 2004 17:31:00 -0000 1.18 @@ -75,8 +75,8 @@ #define GRAVITY 1.0 #define YM_FOR_JUMP 6.0 -#define WALK_ACCELERATION_X 0.02 -#define RUN_ACCELERATION_X 0.03 +#define WALK_ACCELERATION_X 0.03 +#define RUN_ACCELERATION_X 0.04 #define KILL_BOUNCE_YM 8.0 #define SKID_XM 2.0 |
From: Ingo R. <gr...@us...> - 2004-04-20 16:50:43
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4560 Modified Files: configfile.cpp globals.cpp setup.cpp Log Message: - added config options for joystick buttons/axis Index: setup.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/setup.cpp,v retrieving revision 1.44 retrieving revision 1.45 diff -u -d -r1.44 -r1.45 --- setup.cpp 20 Apr 2004 12:12:31 -0000 1.44 +++ setup.cpp 20 Apr 2004 16:50:18 -0000 1.45 @@ -762,8 +762,6 @@ } else { - /* Check for proper joystick configuration: */ - if (SDL_JoystickNumAxes(js) < 2) { fprintf(stderr, @@ -927,6 +925,29 @@ assert(i+1 < argc); joystick_num = atoi(argv[++i]); } + else if (strcmp(argv[i], "--joymap") == 0) + { + assert(i+1 < argc); + if (sscanf(argv[++i], + "%d:%d:%d:%d:%d", + &joystick_keymap.x_axis, + &joystick_keymap.y_axis, + &joystick_keymap.a_button, + &joystick_keymap.b_button, + &joystick_keymap.start_button) != 5) + { + puts("Warning: Invalid or incomplete joymap, should be: 'XAXIS:YAXIS:A:B:START'"); + } + else + { + std::cout << "Using new joymap:\n" + << " X-Axis: " << joystick_keymap.x_axis << "\n" + << " Y-Axis: " << joystick_keymap.y_axis << "\n" + << " A-Button: " << joystick_keymap.a_button << "\n" + << " B-Button: " << joystick_keymap.b_button << "\n" + << " Start-Button: " << joystick_keymap.start_button << std::endl; + } + } else if (strcmp(argv[i], "--worldmap") == 0) { launch_worldmap_mode = true; @@ -1004,6 +1025,8 @@ "\n" "Misc Options:\n" " -j, --joystick NUM Use joystick NUM (default: 0)\n" + " --joymap XAXIS:YAXIS:A:B:START\n" + " Define how joystick buttons and axis should be mapped\n" " --worldmap Start in worldmap-mode (EXPERIMENTAL)\n" " -d, --datadir DIR Load Game data from DIR (default: automatic)\n" " --debug-mode Enables the debug-mode, which is useful for developers.\n" Index: globals.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/globals.cpp,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -r1.15 -r1.16 --- globals.cpp 20 Apr 2004 16:25:57 -0000 1.15 +++ globals.cpp 20 Apr 2004 16:50:18 -0000 1.16 @@ -27,7 +27,7 @@ { a_button = 0; b_button = 1; - start_button = 9; + start_button = 2; x_axis = 0; y_axis = 1; Index: configfile.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/configfile.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- configfile.cpp 24 Mar 2004 16:13:27 -0000 1.1 +++ configfile.cpp 20 Apr 2004 16:50:18 -0000 1.2 @@ -90,6 +90,13 @@ use_joystick = false; else use_joystick = true; + + reader.read_int ("joystick-x", &joystick_keymap.x_axis); + reader.read_int ("joystick-y", &joystick_keymap.y_axis); + reader.read_int ("joystick-a", &joystick_keymap.a_button); + reader.read_int ("joystick-b", &joystick_keymap.b_button); + reader.read_int ("joystick-start", &joystick_keymap.start_button); + reader.read_int ("joystick-deadzone", &joystick_keymap.dead_zone); } void saveconfig (void) @@ -112,6 +119,14 @@ fprintf(config, "\n\t;; joystick number (-1 means no joystick):\n"); fprintf(config, "\t(joystick %d)\n", use_joystick ? joystick_num : -1); + + fprintf(config, "\t(joystick-x %d)\n", joystick_keymap.x_axis); + fprintf(config, "\t(joystick-y %d)\n", joystick_keymap.y_axis); + fprintf(config, "\t(joystick-a %d)\n", joystick_keymap.a_button); + fprintf(config, "\t(joystick-b %d)\n", joystick_keymap.b_button); + fprintf(config, "\t(joystick-start %d)\n", joystick_keymap.start_button); + fprintf(config, "\t(joystick-deadzone %d)\n", joystick_keymap.dead_zone); + fprintf(config, ")\n"); } } |
From: Ingo R. <gr...@us...> - 2004-04-20 16:26:58
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32204 Modified Files: gameloop.cpp globals.cpp globals.h menu.cpp player.cpp player.h worldmap.cpp Log Message: - moved joystick mappings into a struct Index: menu.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/menu.cpp,v retrieving revision 1.41 retrieving revision 1.42 diff -u -d -r1.41 -r1.42 --- menu.cpp 20 Apr 2004 10:42:04 -0000 1.41 +++ menu.cpp 20 Apr 2004 16:25:57 -0000 1.42 @@ -634,7 +634,7 @@ } break; case SDL_JOYAXISMOTION: - if(event.jaxis.axis == JOY_Y) + if(event.jaxis.axis == joystick_keymap.y_axis) { if (event.jaxis.value > 1024) menuaction = MENU_ACTION_DOWN; Index: player.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/player.h,v retrieving revision 1.30 retrieving revision 1.31 diff -u -d -r1.30 -r1.31 --- player.h 20 Apr 2004 11:09:34 -0000 1.30 +++ player.h 20 Apr 2004 16:26:06 -0000 1.31 @@ -46,13 +46,16 @@ #include <vector> -struct player_keymap_type +struct PlayerKeymap { +public: int jump; int duck; int left; int right; int fire; + + PlayerKeymap(); }; struct player_input_type @@ -101,9 +104,7 @@ class Player { - public: - player_keymap_type keymap; - +public: player_input_type input; bool got_coffee; int size; @@ -123,7 +124,7 @@ Timer frame_timer; Physic physic; - public: +public: void init(); int key_event(SDLKey key, int state); void level_begin(); @@ -140,10 +141,14 @@ bool on_ground(); bool under_solid(); - private: +private: void handle_horizontal_input(); void handle_vertical_input(); void remove_powerups(); }; #endif /*SUPERTUX_PLAYER_H*/ + +/* Local Variables: */ +/* mode:c++ */ +/* End: */ Index: globals.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/globals.cpp,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- globals.cpp 20 Apr 2004 12:24:28 -0000 1.14 +++ globals.cpp 20 Apr 2004 16:25:57 -0000 1.15 @@ -23,12 +23,19 @@ /** The datadir prefix prepended when loading game data file */ std::string datadir; -int JOY_A = 0; -int JOY_B = 1; -int JOY_START = 9; +JoystickKeymap::JoystickKeymap() +{ + a_button = 0; + b_button = 1; + start_button = 9; + + x_axis = 0; + y_axis = 1; + + dead_zone = 4096; +} -int JOY_X = 0; -int JOY_Y = 1; +JoystickKeymap joystick_keymap; SDL_Surface * screen; Text* black_text; @@ -47,7 +54,7 @@ bool use_fullscreen; bool debug_mode; bool show_fps; -float game_speed = 1.0f; +float game_speed = 1.2f; int joystick_num = 0; char* level_startup_file = 0; Index: globals.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/globals.h,v retrieving revision 1.26 retrieving revision 1.27 diff -u -d -r1.26 -r1.27 --- globals.h 20 Apr 2004 12:24:28 -0000 1.26 +++ globals.h 20 Apr 2004 16:25:57 -0000 1.27 @@ -30,13 +30,21 @@ extern std::string datadir; -/* Joystick buttons and axes: */ -extern int JOY_A; -extern int JOY_B; -extern int JOY_START; +struct JoystickKeymap +{ + int a_button; + int b_button; + int start_button; -extern int JOY_X; -extern int JOY_Y; + int x_axis; + int y_axis; + + int dead_zone; + + JoystickKeymap(); +}; + +extern JoystickKeymap joystick_keymap; extern SDL_Surface * screen; extern Text* black_text; @@ -70,6 +78,4 @@ int wait_for_event(SDL_Event& event,unsigned int min_delay = 0, unsigned int max_delay = 0, bool empty_events = false); -#define JOYSTICK_DEAD_ZONE 4096 - #endif /* SUPERTUX_GLOBALS_H */ Index: player.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/player.cpp,v retrieving revision 1.46 retrieving revision 1.47 diff -u -d -r1.46 -r1.47 --- player.cpp 20 Apr 2004 11:09:34 -0000 1.46 +++ player.cpp 20 Apr 2004 16:25:57 -0000 1.47 @@ -59,6 +59,17 @@ Surface* bigcape_right[2]; Surface* bigcape_left[2]; +PlayerKeymap keymap; + +PlayerKeymap::PlayerKeymap() +{ + keymap.jump = SDLK_UP; + keymap.duck = SDLK_DOWN; + keymap.left = SDLK_LEFT; + keymap.right = SDLK_RIGHT; + keymap.fire = SDLK_LCTRL; +} + void player_input_init(player_input_type* pplayer_input) { pplayer_input->down = UP; @@ -96,12 +107,6 @@ player_input_init(&input); - keymap.jump = SDLK_UP; - keymap.duck = SDLK_DOWN; - keymap.left = SDLK_LEFT; - keymap.right = SDLK_RIGHT; - keymap.fire = SDLK_LCTRL; - invincible_timer.init(true); skidding_timer.init(true); safe_timer.init(true); Index: worldmap.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/worldmap.cpp,v retrieving revision 1.39 retrieving revision 1.40 diff -u -d -r1.39 -r1.40 --- worldmap.cpp 20 Apr 2004 12:24:28 -0000 1.39 +++ worldmap.cpp 20 Apr 2004 16:26:08 -0000 1.40 @@ -408,26 +408,26 @@ break; case SDL_JOYAXISMOTION: - if (event.jaxis.axis == JOY_X) + if (event.jaxis.axis == joystick_keymap.x_axis) { - if (event.jaxis.value < -JOYSTICK_DEAD_ZONE) + if (event.jaxis.value < -joystick_keymap.dead_zone) input_direction = WEST; - else if (event.jaxis.value > JOYSTICK_DEAD_ZONE) + else if (event.jaxis.value > joystick_keymap.dead_zone) input_direction = EAST; } - else if (event.jaxis.axis == JOY_Y) + else if (event.jaxis.axis == joystick_keymap.y_axis) { - if (event.jaxis.value > JOYSTICK_DEAD_ZONE) + if (event.jaxis.value > joystick_keymap.dead_zone) input_direction = SOUTH; - else if (event.jaxis.value < -JOYSTICK_DEAD_ZONE) + else if (event.jaxis.value < -joystick_keymap.dead_zone) input_direction = NORTH; } break; case SDL_JOYBUTTONDOWN: - if (event.jbutton.button == JOY_B) + if (event.jbutton.button == joystick_keymap.b_button) enter_level = true; - else if (event.jbutton.button == JOY_START) + else if (event.jbutton.button == joystick_keymap.start_button) on_escape_press(); break; Index: gameloop.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/gameloop.cpp,v retrieving revision 1.86 retrieving revision 1.87 diff -u -d -r1.86 -r1.87 --- gameloop.cpp 20 Apr 2004 12:24:28 -0000 1.86 +++ gameloop.cpp 20 Apr 2004 16:25:56 -0000 1.87 @@ -280,14 +280,14 @@ break; case SDL_JOYAXISMOTION: - if (event.jaxis.axis == JOY_X) + if (event.jaxis.axis == joystick_keymap.x_axis) { - if (event.jaxis.value < -JOYSTICK_DEAD_ZONE) + if (event.jaxis.value < -joystick_keymap.dead_zone) { tux.input.left = DOWN; tux.input.right = UP; } - else if (event.jaxis.value > JOYSTICK_DEAD_ZONE) + else if (event.jaxis.value > joystick_keymap.dead_zone) { tux.input.left = UP; tux.input.right = DOWN; @@ -298,11 +298,11 @@ tux.input.right = DOWN; } } - else if (event.jaxis.axis == JOY_Y) + else if (event.jaxis.axis == joystick_keymap.y_axis) { - if (event.jaxis.value > JOYSTICK_DEAD_ZONE) + if (event.jaxis.value > joystick_keymap.dead_zone) tux.input.down = DOWN; - else if (event.jaxis.value < -JOYSTICK_DEAD_ZONE) + else if (event.jaxis.value < -joystick_keymap.dead_zone) tux.input.down = UP; else tux.input.down = UP; @@ -310,17 +310,17 @@ break; case SDL_JOYBUTTONDOWN: - if (event.jbutton.button == JOY_A) + if (event.jbutton.button == joystick_keymap.a_button) tux.input.up = DOWN; - else if (event.jbutton.button == JOY_B) + else if (event.jbutton.button == joystick_keymap.b_button) tux.input.fire = DOWN; - else if (event.jbutton.button == JOY_START) + else if (event.jbutton.button == joystick_keymap.start_button) on_escape_press(); break; case SDL_JOYBUTTONUP: - if (event.jbutton.button == JOY_A) + if (event.jbutton.button == joystick_keymap.a_button) tux.input.up = UP; - else if (event.jbutton.button == JOY_B) + else if (event.jbutton.button == joystick_keymap.b_button) tux.input.fire = UP; break; |
From: Ricardo C. <rm...@us...> - 2004-04-20 15:48:21
|
Update of /cvsroot/super-tux/supertux/data/images/shared In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24407/data/images/shared Modified Files: mriceblock-flat-left.png mriceblock-flat-right.png Log Message: Improved my flat graphics hack a bit. Someone should do a from scratch ones, but this work for now. Index: mriceblock-flat-left.png =================================================================== RCS file: /cvsroot/super-tux/supertux/data/images/shared/mriceblock-flat-left.png,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 Binary files /tmp/cvszUM1Mc and /tmp/cvsZqZGMW differ Index: mriceblock-flat-right.png =================================================================== RCS file: /cvsroot/super-tux/supertux/data/images/shared/mriceblock-flat-right.png,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 Binary files /tmp/cvsEqwXTj and /tmp/cvsiEhgY3 differ |
From: Ricardo C. <rm...@us...> - 2004-04-20 14:30:13
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7630/src Modified Files: leveleditor.cpp Log Message: Just removed two printfs I have mistakelly committed. Index: leveleditor.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/leveleditor.cpp,v retrieving revision 1.57 retrieving revision 1.58 diff -u -d -r1.57 -r1.58 --- leveleditor.cpp 20 Apr 2004 11:37:10 -0000 1.57 +++ leveleditor.cpp 20 Apr 2004 14:30:03 -0000 1.58 @@ -345,11 +345,8 @@ mouse_cursor->draw(); -printf("done: %i\n", done); - if(done) { -printf("done\n"); le_quit(); return 0; } |
From: Ingo R. <gr...@us...> - 2004-04-20 12:24:49
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13494 Modified Files: defines.h gameloop.cpp globals.cpp globals.h worldmap.cpp Log Message: - turned joystick defines into variables Index: defines.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/defines.h,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -r1.16 -r1.17 --- defines.h 20 Apr 2004 11:09:33 -0000 1.16 +++ defines.h 20 Apr 2004 12:24:28 -0000 1.17 @@ -32,16 +32,6 @@ #define FPS (1000 / 25) - -/* Joystick buttons and axes: */ - -#define JOY_A 0 -#define JOY_B 1 -#define JOY_START 9 - -#define JOY_X 0 -#define JOY_Y 1 - /* Direction (keyboard/joystick) states: */ #define UP 0 Index: globals.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/globals.cpp,v retrieving revision 1.13 retrieving revision 1.14 diff -u -d -r1.13 -r1.14 --- globals.cpp 20 Apr 2004 11:09:33 -0000 1.13 +++ globals.cpp 20 Apr 2004 12:24:28 -0000 1.14 @@ -23,6 +23,13 @@ /** The datadir prefix prepended when loading game data file */ std::string datadir; +int JOY_A = 0; +int JOY_B = 1; +int JOY_START = 9; + +int JOY_X = 0; +int JOY_Y = 1; + SDL_Surface * screen; Text* black_text; Text* gold_text; Index: globals.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/globals.h,v retrieving revision 1.25 retrieving revision 1.26 diff -u -d -r1.25 -r1.26 --- globals.h 20 Apr 2004 11:09:33 -0000 1.25 +++ globals.h 20 Apr 2004 12:24:28 -0000 1.26 @@ -30,6 +30,14 @@ extern std::string datadir; +/* Joystick buttons and axes: */ +extern int JOY_A; +extern int JOY_B; +extern int JOY_START; + +extern int JOY_X; +extern int JOY_Y; + extern SDL_Surface * screen; extern Text* black_text; extern Text* gold_text; Index: worldmap.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/worldmap.cpp,v retrieving revision 1.38 retrieving revision 1.39 diff -u -d -r1.38 -r1.39 --- worldmap.cpp 20 Apr 2004 10:42:05 -0000 1.38 +++ worldmap.cpp 20 Apr 2004 12:24:28 -0000 1.39 @@ -408,20 +408,19 @@ break; case SDL_JOYAXISMOTION: - switch(event.jaxis.axis) + if (event.jaxis.axis == JOY_X) { - case JOY_X: if (event.jaxis.value < -JOYSTICK_DEAD_ZONE) input_direction = WEST; else if (event.jaxis.value > JOYSTICK_DEAD_ZONE) input_direction = EAST; - break; - case JOY_Y: + } + else if (event.jaxis.axis == JOY_Y) + { if (event.jaxis.value > JOYSTICK_DEAD_ZONE) input_direction = SOUTH; else if (event.jaxis.value < -JOYSTICK_DEAD_ZONE) input_direction = NORTH; - break; } break; Index: gameloop.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/gameloop.cpp,v retrieving revision 1.85 retrieving revision 1.86 diff -u -d -r1.85 -r1.86 --- gameloop.cpp 20 Apr 2004 12:12:31 -0000 1.85 +++ gameloop.cpp 20 Apr 2004 12:24:28 -0000 1.86 @@ -280,9 +280,8 @@ break; case SDL_JOYAXISMOTION: - switch(event.jaxis.axis) + if (event.jaxis.axis == JOY_X) { - case JOY_X: if (event.jaxis.value < -JOYSTICK_DEAD_ZONE) { tux.input.left = DOWN; @@ -298,20 +297,18 @@ tux.input.left = DOWN; tux.input.right = DOWN; } - break; - case JOY_Y: + } + else if (event.jaxis.axis == JOY_Y) + { if (event.jaxis.value > JOYSTICK_DEAD_ZONE) tux.input.down = DOWN; else if (event.jaxis.value < -JOYSTICK_DEAD_ZONE) tux.input.down = UP; else tux.input.down = UP; - - break; - default: - break; } break; + case SDL_JOYBUTTONDOWN: if (event.jbutton.button == JOY_A) tux.input.up = DOWN; |
From: Ingo R. <gr...@us...> - 2004-04-20 12:12:41
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11456 Modified Files: gameloop.cpp setup.cpp Log Message: - fixed some more menu issues - removed highscore loading from gameloop Index: setup.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/setup.cpp,v retrieving revision 1.43 retrieving revision 1.44 diff -u -d -r1.43 -r1.44 --- setup.cpp 20 Apr 2004 11:37:10 -0000 1.43 +++ setup.cpp 20 Apr 2004 12:12:31 -0000 1.44 @@ -463,7 +463,7 @@ { int slot = load_game_menu->check(); - if(slot != -1) + if(slot != -1 && load_game_menu->get_item(slot).kind == MN_ACTION) { WorldMapNS::WorldMap worldmap; Index: gameloop.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/gameloop.cpp,v retrieving revision 1.84 retrieving revision 1.85 diff -u -d -r1.84 -r1.85 --- gameloop.cpp 20 Apr 2004 11:09:33 -0000 1.84 +++ gameloop.cpp 20 Apr 2004 12:12:31 -0000 1.85 @@ -115,9 +115,6 @@ if (st_gl_mode != ST_GL_DEMO_GAME) { - if(st_gl_mode != ST_GL_TEST) - load_hs(); - if(st_gl_mode == ST_GL_PLAY || st_gl_mode == ST_GL_LOAD_LEVEL_FILE) levelintro(); } |
From: Ricardo C. <rm...@us...> - 2004-04-20 11:43:51
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5891/src Modified Files: title.cpp Log Message: Recoded credits code, in order to respect fonts height. (if you think there should be more space between items, just change ITEMS_SPACE). Also fixed a mistake that was making SDL_QUIT signal to never be used. Index: title.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/title.cpp,v retrieving revision 1.51 retrieving revision 1.52 diff -u -d -r1.51 -r1.52 --- title.cpp 20 Apr 2004 11:21:53 -0000 1.51 +++ title.cpp 20 Apr 2004 11:43:43 -0000 1.52 @@ -58,7 +58,7 @@ static bool walking; static Timer random_timer; -static int frame, i; +static int frame; static unsigned int last_update_time; static unsigned int update_time; @@ -265,12 +265,9 @@ { Menu::current()->event(event); } - else - { - // FIXME: QUIT signal should be handled more generic, not locally - if (event.type == SDL_QUIT) - Menu::set_current(0); - } + // FIXME: QUIT signal should be handled more generic, not locally + if (event.type == SDL_QUIT) + Menu::set_current(0); } /* Draw the background: */ @@ -367,13 +364,14 @@ #define MAX_VEL 10 #define SPEED 1 #define SCROLL 60 +#define ITEMS_SPACE 4 void display_credits() { int done; int scroll, speed; + int y; Timer timer; - int n,d; int length; FILE* fi; char temp[1024]; @@ -406,8 +404,6 @@ speed = 2; done = 0; - n = d = 0; - length = names.num_items; SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL); @@ -458,26 +454,33 @@ white_big_text->drawf("- Credits -", 0, screen->h-scroll, A_HMIDDLE, A_TOP, 2); - for(i = 0, n = 0, d = 0; i < length; i++,n++,d++) + y = 0; + for(int i = 0; i < length; i++) { - if(names.item[i] == "") - n--; - else - { - if(names.item[i][0] == ' ') - white_small_text->drawf(names.item[i], 0, 60+screen->h+(n*18)+(d*18)-scroll-10, A_HMIDDLE, A_TOP, 1); - else if(names.item[i][0] == ' ') - white_text->drawf(names.item[i], 0, 60+screen->h+(n*18)+(d*18)-scroll, A_HMIDDLE, A_TOP, 1); - else if(names.item[i+1][0] == '-' || names.item[i][0] == '-') - white_big_text->drawf(names.item[i], 0, 60+screen->h+(n*18)+(d*18)-scroll, A_HMIDDLE, A_TOP, 3); - else - blue_text->drawf(names.item[i], 0, 60+screen->h+(n*18)+(d*18)-scroll, A_HMIDDLE, A_TOP, 1); - } + switch(names.item[i][0]) + { + case ' ': + white_small_text->drawf(names.item[i], 0, 60+screen->h+y-scroll, A_HMIDDLE, A_TOP, 1); + y += white_small_text->h+ITEMS_SPACE; + break; + case ' ': + white_text->drawf(names.item[i], 0, 60+screen->h+y-scroll, A_HMIDDLE, A_TOP, 1); + y += white_text->h+ITEMS_SPACE; + break; + case '-': + white_big_text->drawf(names.item[i], 0, 60+screen->h+y-scroll, A_HMIDDLE, A_TOP, 3); + y += white_big_text->h+ITEMS_SPACE; + break; + default: + blue_text->drawf(names.item[i], 0, 60+screen->h+y-scroll, A_HMIDDLE, A_TOP, 1); + y += blue_text->h+ITEMS_SPACE; + break; + } } flipscreen(); - if(60+screen->h+(n*18)+(d*18)-scroll < 0 && 20+60+screen->h+(n*18)+(d*18)-scroll < 0) + if(60+screen->h+y-scroll < 0 && 20+60+screen->h+y-scroll < 0) done = 1; scroll += speed; |
From: Ingo R. <gr...@us...> - 2004-04-20 11:37:20
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4697 Modified Files: level.cpp leveleditor.cpp setup.cpp special.cpp Log Message: - fixed level editor menus a bit (still not 100% working) - added resetpoint saving to Level Index: level.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/level.cpp,v retrieving revision 1.40 retrieving revision 1.41 diff -u -d -r1.40 -r1.41 --- level.cpp 20 Apr 2004 11:09:33 -0000 1.40 +++ level.cpp 20 Apr 2004 11:37:10 -0000 1.41 @@ -560,6 +560,13 @@ } fprintf( fi,")\n"); + + fprintf( fi,"(reset-points\n"); + for(std::vector<ResetPoint>::iterator i = reset_points.begin(); + i != reset_points.end(); ++i) + fprintf( fi,"(point (x %d) (y %d))\n",i->x, i->y); + fprintf( fi,")\n"); + fprintf( fi,"(objects\n"); for(std::vector<BadGuyData>::iterator it = badguy_data.begin(); Index: setup.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/setup.cpp,v retrieving revision 1.42 retrieving revision 1.43 diff -u -d -r1.42 -r1.43 --- setup.cpp 19 Apr 2004 19:06:45 -0000 1.42 +++ setup.cpp 20 Apr 2004 11:37:10 -0000 1.43 @@ -1,14 +1,21 @@ -/* - setup.c - - Super Tux - Setup - - by Bill Kendrick - bi...@ne... - http://www.newbreedsoftware.com/supertux/ - - April 11, 2000 - March 15, 2004 -*/ +// $Id$ +// +// SuperTux - A Jump'n Run +// Copyright (C) 2000 Bill Kendrick <bi...@ne...> +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include <assert.h> #include <stdio.h> Index: leveleditor.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/leveleditor.cpp,v retrieving revision 1.56 retrieving revision 1.57 diff -u -d -r1.56 -r1.57 --- leveleditor.cpp 20 Apr 2004 11:09:33 -0000 1.56 +++ leveleditor.cpp 20 Apr 2004 11:37:10 -0000 1.57 @@ -213,12 +213,13 @@ /* draw editor interface */ le_drawinterface(); - if(Menu::current()) + Menu* menu = Menu::current(); + if(menu) { - Menu::current()->draw(); - Menu::current()->action(); + menu->draw(); + menu->action(); - if(Menu::current() == leveleditor_menu) + if(menu == leveleditor_menu) { switch (leveleditor_menu->check()) { @@ -233,7 +234,7 @@ break; } } - else if(Menu::current() == level_settings_menu) + else if(menu == level_settings_menu) { switch (level_settings_menu->check()) { @@ -247,7 +248,7 @@ break; } } - else if(Menu::current() == select_tilegroup_menu) + else if(menu == select_tilegroup_menu) { int it = -1; switch (it = select_tilegroup_menu->check()) @@ -263,7 +264,7 @@ break; } } - else if(Menu::current() == subset_load_menu) + else if(menu == subset_load_menu) { switch (i = subset_load_menu->check()) { @@ -292,7 +293,7 @@ break; } } - else if(Menu::current() == subset_new_menu) + else if(menu == subset_new_menu) { if(subset_new_menu->item[2].input[0] == '\0') subset_new_menu->item[3].kind = MN_DEACTIVE; @@ -324,7 +325,7 @@ } } } - else if(Menu::current() == subset_settings_menu) + else if(menu == subset_settings_menu) { if(le_level_subset.title.compare(subset_settings_menu->item[2].input) == 0 && le_level_subset.description.compare(subset_settings_menu->item[3].input) == 0 ) subset_settings_menu->item[5].kind = MN_DEACTIVE; Index: special.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/special.cpp,v retrieving revision 1.21 retrieving revision 1.22 diff -u -d -r1.21 -r1.22 --- special.cpp 19 Apr 2004 14:27:11 -0000 1.21 +++ special.cpp 20 Apr 2004 11:37:10 -0000 1.22 @@ -1,14 +1,21 @@ +// $Id$ // -// C Implementation: special -// -// Description: -// -// -// Author: Tobias Glaesser <tob...@gm...> & Bill Kendrick, (C) 2004 +// SuperTux - A Jump'n Run +// Copyright (C) 2003 Tobias Glaesser <tob...@gm...> // -// Copyright: See COPYING file that comes with this distribution +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. // +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. // +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include <assert.h> #include "SDL.h" |
From: Ricardo C. <rm...@us...> - 2004-04-20 11:22:04
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2188/src Modified Files: title.cpp Log Message: Fixed a little mistake that was making title to not be shutdown. Index: title.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/title.cpp,v retrieving revision 1.50 retrieving revision 1.51 diff -u -d -r1.50 -r1.51 --- title.cpp 20 Apr 2004 11:09:34 -0000 1.50 +++ title.cpp 20 Apr 2004 11:21:53 -0000 1.51 @@ -315,7 +315,7 @@ display_credits(); Menu::set_current(main_menu); break; - case 5: + case 6: Menu::set_current(0); break; } |
From: Ingo R. <gr...@us...> - 2004-04-20 10:42:15
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27973 Modified Files: gameloop.cpp high_scores.cpp leveleditor.cpp menu.cpp menu.h title.cpp worldmap.cpp Log Message: - changed Menu::check() semantics a bit - speeded up the contrib menu a lot - fixed a few other menu issues - might have broken editor a bit, needs more testing Index: menu.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/menu.cpp,v retrieving revision 1.40 retrieving revision 1.41 diff -u -d -r1.40 -r1.41 --- menu.cpp 19 Apr 2004 21:54:34 -0000 1.40 +++ menu.cpp 20 Apr 2004 10:42:04 -0000 1.41 @@ -55,16 +55,17 @@ Menu* contrib_menu = 0; Menu* contrib_subset_menu = 0; -std::stack<Menu*> Menu::last_menus; +std::vector<Menu*> Menu::last_menus; Menu* Menu::current_ = 0; void Menu::push_current(Menu* pmenu) { if (current_) - last_menus.push(current_); + last_menus.push_back(current_); - set_current(pmenu); + current_ = pmenu; + current_->effect.start(500); } void @@ -72,18 +73,22 @@ { if (!last_menus.empty()) { - set_current(last_menus.top()); - last_menus.pop(); + current_ = last_menus.back(); + current_->effect.start(500); + + last_menus.pop_back(); } else { - set_current(0); + current_ = 0; } } void Menu::set_current(Menu* menu) { + last_menus.clear(); + if (menu) menu->effect.start(500); @@ -158,6 +163,7 @@ Menu::Menu() { + hit_item = -1; menuaction = MENU_ACTION_NONE; delete_character = 0; mn_input_char = '\0'; @@ -172,8 +178,8 @@ void Menu::set_pos(int x, int y, float rw, float rh) { - pos_x = x + (int)((float)width() * rw); - pos_y = y + (int)((float)height() * rh); + pos_x = x + (int)((float)get_width() * rw); + pos_y = y + (int)((float)get_height() * rh); } void @@ -206,6 +212,7 @@ void Menu::action() { + hit_item = -1; if(item.size() != 0) { switch(menuaction) @@ -248,6 +255,7 @@ case MENU_ACTION_HIT: { + hit_item = active_item; switch (item[active_item].kind) { case MN_GOTO: @@ -265,6 +273,7 @@ case MN_TEXTFIELD: case MN_NUMFIELD: case MN_CONTROLFIELD: + Menu::set_current(0); item[active_item].toggled = true; break; @@ -338,18 +347,21 @@ int Menu::check() { + return hit_item; + /* if (item.size() != 0) { if((item[active_item].kind == MN_ACTION || item[active_item].kind == MN_TEXTFIELD || item[active_item].kind == MN_NUMFIELD) && item[active_item].toggled) - { + { item[active_item].toggled = false; Menu::set_current(0); return active_item; } - else if(item[active_item].kind == MN_TOGGLE || item[active_item].kind == MN_GOTO) + else if(item[active_item].kind == MN_TOGGLE + || item[active_item].kind == MN_GOTO) { return active_item; } @@ -358,6 +370,7 @@ } else return -1; + */ } void @@ -506,7 +519,7 @@ } } -int Menu::width() +int Menu::get_width() const { /* The width of the menu has to be more than the width of the text with the most characters */ @@ -525,7 +538,7 @@ return (menu_width * 16 + 24); } -int Menu::height() +int Menu::get_height() const { return item.size() * 24; } @@ -534,8 +547,8 @@ void Menu::draw() { - int menu_height = height(); - int menu_width = width(); + int menu_height = get_height(); + int menu_width = get_width(); /* Draw a transparent background */ fillrect(pos_x - menu_width/2, @@ -635,10 +648,10 @@ case SDL_MOUSEBUTTONDOWN: x = event.motion.x; y = event.motion.y; - if(x > pos_x - width()/2 && - x < pos_x + width()/2 && - y > pos_y - height()/2 && - y < pos_y + height()/2) + if(x > pos_x - get_width()/2 && + x < pos_x + get_width()/2 && + y > pos_y - get_height()/2 && + y < pos_y + get_height()/2) { menuaction = MENU_ACTION_HIT; } @@ -646,12 +659,12 @@ case SDL_MOUSEMOTION: x = event.motion.x; y = event.motion.y; - if(x > pos_x - width()/2 && - x < pos_x + width()/2 && - y > pos_y - height()/2 && - y < pos_y + height()/2) + if(x > pos_x - get_width()/2 && + x < pos_x + get_width()/2 && + y > pos_y - get_height()/2 && + y < pos_y + get_height()/2) { - active_item = (y - (pos_y - height()/2)) / 24; + active_item = (y - (pos_y - get_height()/2)) / 24; mouse_cursor->set_state(MC_LINK); } else Index: menu.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/menu.h,v retrieving revision 1.39 retrieving revision 1.40 diff -u -d -r1.39 -r1.40 --- menu.h 19 Apr 2004 21:54:34 -0000 1.39 +++ menu.h 20 Apr 2004 10:42:05 -0000 1.40 @@ -22,7 +22,6 @@ #include <SDL.h> #include <vector> -#include <stack> #include "texture.h" #include "timer.h" #include "type.h" @@ -64,7 +63,7 @@ class Menu { private: - static std::stack<Menu*> last_menus; + static std::vector<Menu*> last_menus; static Menu* current_; static void push_current(Menu* pmenu); @@ -89,6 +88,10 @@ MENU_ACTION_REMOVE }; + /** Number of the item that got 'hit' (ie. pressed) in the last + event()/action() call, -1 if none */ + int hit_item; + // position of the menu (ie. center of the menu, not top/left) int pos_x; int pos_y; @@ -101,9 +104,6 @@ int delete_character; char mn_input_char; - int width(); - int height(); - public: Timer effect; int arrange_left; @@ -116,22 +116,27 @@ void additem(MenuItem* pmenu_item); void additem(MenuItemKind kind, const std::string& text, int init_toggle, Menu* target_menu); - void action (); + + void action (); /** Remove all entries from the menu */ void clear(); - /** Check, if the value of the active menu item has changed. FIXME: - Somebody should document the exact meaning of this function a - bit more */ + /** Return the index of the menu item that was 'hit' (ie. the user + clicked on it) in the last event() call */ int check (); + MenuItem& get_item(int index) { return item[index]; } + void draw (); void draw_item(int index, int menu_width, int menu_height); void set_pos(int x, int y, float rw = 0, float rh = 0); /** translate a SDL_Event into a menu_action */ void event(SDL_Event& event); + + int get_width() const; + int get_height() const; }; extern Surface* checkbox; Index: leveleditor.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/leveleditor.cpp,v retrieving revision 1.54 retrieving revision 1.55 diff -u -d -r1.54 -r1.55 --- leveleditor.cpp 19 Apr 2004 19:22:27 -0000 1.54 +++ leveleditor.cpp 20 Apr 2004 10:42:04 -0000 1.55 @@ -210,8 +210,8 @@ if(Menu::current()) { - Menu::current()->action(); Menu::current()->draw(); + Menu::current()->action(); if(Menu::current() == leveleditor_menu) { Index: title.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/title.cpp,v retrieving revision 1.48 retrieving revision 1.49 diff -u -d -r1.48 -r1.49 --- title.cpp 19 Apr 2004 21:21:00 -0000 1.48 +++ title.cpp 20 Apr 2004 10:42:05 -0000 1.49 @@ -58,33 +58,26 @@ std::vector<st_subset> contrib_subsets; std::string current_contrib_subset; -void update_contrib_menu() +void generate_contrib_menu() { - // FIXME: Hack to update only once - static bool up_to_date = false; - - if (!up_to_date) - { - string_list_type level_subsets = dsubdirs("/levels", "info"); + string_list_type level_subsets = dsubdirs("/levels", "info"); - contrib_menu->clear(); - contrib_menu->additem(MN_LABEL,"Contrib Levels",0,0); - contrib_menu->additem(MN_HL,"",0,0); + contrib_menu->clear(); + contrib_menu->additem(MN_LABEL,"Contrib Levels",0,0); + contrib_menu->additem(MN_HL,"",0,0); - for (int i = 0; i < level_subsets.num_items; ++i) - { - st_subset subset; - subset.load(level_subsets.item[i]); - contrib_menu->additem(MN_GOTO, subset.title.c_str(), i, contrib_subset_menu); - contrib_subsets.push_back(subset); - } + for (int i = 0; i < level_subsets.num_items; ++i) + { + st_subset subset; + subset.load(level_subsets.item[i]); + contrib_menu->additem(MN_GOTO, subset.title.c_str(), i, contrib_subset_menu); + contrib_subsets.push_back(subset); + } - contrib_menu->additem(MN_HL,"",0,0); - contrib_menu->additem(MN_BACK,"Back",0,0); + contrib_menu->additem(MN_HL,"",0,0); + contrib_menu->additem(MN_BACK,"Back",0,0); - string_list_free(&level_subsets); - up_to_date = true; - } + string_list_free(&level_subsets); } void check_contrib_menu() @@ -133,11 +126,14 @@ int index = contrib_subset_menu->check(); if (index != -1) { - index -= 1; // FIXME: Hack - std::cout << "Sarting level: " << index << std::endl; - GameSession session(current_contrib_subset, index, ST_GL_PLAY); - session.run(); - Menu::set_current(main_menu); + if (contrib_subset_menu->get_item(index).kind == MN_ACTION) + { + index -= 1; // FIXME: Hack + std::cout << "Sarting level: " << index << std::endl; + GameSession session(current_contrib_subset, index, ST_GL_PLAY); + session.run(); + Menu::set_current(main_menu); + } } } @@ -283,59 +279,61 @@ 0, 420, 0); /* Don't draw menu, if quit is true */ - if(Menu::current()) - { - Menu::current()->action(); - Menu::current()->draw(); - } - - if(Menu::current() == main_menu) + Menu* menu = Menu::current(); + if(menu) { - switch (main_menu->check()) + menu->draw(); + menu->action(); + + if(menu == main_menu) { - case 0: - // Start Game, ie. goto the slots menu - update_load_save_game_menu(load_game_menu); - break; - case 1: - // Contrib Menu - update_contrib_menu(); - break; - case 3: - leveleditor(1); - Menu::set_current(main_menu); - break; - case 4: - display_credits(); - Menu::set_current(main_menu); - break; - case 5: - Menu::set_current(0); - break; + switch (main_menu->check()) + { + case 0: + // Start Game, ie. goto the slots menu + update_load_save_game_menu(load_game_menu); + break; + case 1: + // Contrib Menu + puts("Entering contrib menu"); + generate_contrib_menu(); + break; + case 3: + leveleditor(1); + Menu::set_current(main_menu); + break; + case 4: + display_credits(); + Menu::set_current(main_menu); + break; + case 5: + Menu::set_current(0); + break; + } } - } - else if(Menu::current() == options_menu) - { - process_options_menu(); - } - else if(Menu::current() == load_game_menu) - { - if (process_load_game_menu()) + else if(menu == options_menu) { - // FIXME: shouldn't be needed if GameSession doesn't relay on global variables - // reset tux - scroll_x = 0; - //titletux.level_begin(); - update_time = st_get_ticks(); + process_options_menu(); + } + else if(menu == load_game_menu) + { + if (process_load_game_menu()) + { + // FIXME: shouldn't be needed if GameSession doesn't relay on global variables + // reset tux + scroll_x = 0; + //titletux.level_begin(); + update_time = st_get_ticks(); + } + } + else if(menu == contrib_menu) + { + check_contrib_menu(); + } + else if (menu == contrib_subset_menu) + { + check_contrib_subset_menu(); } - } - else if(Menu::current() == contrib_menu) - { - check_contrib_menu(); - } - else if (Menu::current() == contrib_subset_menu) - { - check_contrib_subset_menu(); } mouse_cursor->draw(); Index: worldmap.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/worldmap.cpp,v retrieving revision 1.37 retrieving revision 1.38 diff -u -d -r1.37 -r1.38 --- worldmap.cpp 19 Apr 2004 21:21:00 -0000 1.37 +++ worldmap.cpp 20 Apr 2004 10:42:05 -0000 1.38 @@ -567,9 +567,12 @@ tux->update(0.33f); } - if(Menu::current()) + Menu* menu = Menu::current(); + if(menu) { - if(Menu::current() == worldmap_menu) + menu->action(); + + if(menu == worldmap_menu) { switch (worldmap_menu->check()) { @@ -585,6 +588,10 @@ break; } } + else if(menu == options_menu) + { + process_options_menu(); + } } } @@ -707,7 +714,6 @@ if(Menu::current()) { - Menu::current()->action(); Menu::current()->draw(); mouse_cursor->draw(); } Index: high_scores.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/high_scores.cpp,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- high_scores.cpp 19 Apr 2004 19:22:27 -0000 1.14 +++ high_scores.cpp 20 Apr 2004 10:42:04 -0000 1.15 @@ -94,8 +94,8 @@ sprintf(str, "%d", hs_score); yellow_nums->draw(str, 350, 170, 1, NO_UPDATE); - Menu::current()->action(); Menu::current()->draw(); + Menu::current()->action(); flipscreen(); Index: gameloop.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/gameloop.cpp,v retrieving revision 1.82 retrieving revision 1.83 diff -u -d -r1.82 -r1.83 --- gameloop.cpp 19 Apr 2004 22:47:36 -0000 1.82 +++ gameloop.cpp 20 Apr 2004 10:42:04 -0000 1.83 @@ -393,7 +393,6 @@ if(Menu::current()) { - Menu::current()->action(); Menu::current()->draw(); mouse_cursor->draw(); } @@ -405,6 +404,7 @@ GameSession::ExitStatus GameSession::run() { + Menu::set_current(0); Player* tux = world->get_tux(); current_ = this; @@ -448,10 +448,13 @@ tux->input.old_fire = tux->input.fire; process_events(); - - if(Menu::current()) + + Menu* menu = Menu::current(); + if(menu) { - if(Menu::current() == game_menu) + menu->action(); + + if(menu == game_menu) { switch (game_menu->check()) { @@ -464,11 +467,11 @@ break; } } - else if(Menu::current() == options_menu) + else if(menu == options_menu) { process_options_menu(); } - else if(Menu::current() == load_game_menu ) + else if(menu == load_game_menu ) { process_load_game_menu(); } |
From: Ingo R. <gr...@us...> - 2004-04-19 23:02:30
|
Update of /cvsroot/super-tux/supertux/data/images/shared In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4168 Added Files: resetpoint.png Log Message: - added resetpoint gfx (level editor only) --- NEW FILE: resetpoint.png --- (This appears to be a binary file; contents omitted.) |
From: Ingo R. <gr...@us...> - 2004-04-19 22:47:52
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1601 Modified Files: gameloop.cpp level.cpp level.h Log Message: - implemented reset points Index: level.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/level.cpp,v retrieving revision 1.38 retrieving revision 1.39 diff -u -d -r1.38 -r1.39 --- level.cpp 18 Apr 2004 22:36:03 -0000 1.38 +++ level.cpp 19 Apr 2004 22:47:36 -0000 1.39 @@ -315,7 +315,29 @@ reader.read_int_vector("foreground-tm", &fg_tm); - { + { // Read ResetPoints + lisp_object_t* cur = 0; + if (reader.read_lisp("reset-points", &cur)) + { + while (!lisp_nil_p(cur)) + { + lisp_object_t* data = lisp_car(cur); + + ResetPoint pos; + + LispReader reader(lisp_cdr(data)); + if (reader.read_int("x", &pos.x) + && reader.read_int("y", &pos.y)) + { + reset_points.push_back(pos); + } + + cur = lisp_cdr(cur); + } + } + } + + { // Read BadGuys lisp_object_t* cur = 0; if (reader.read_lisp("objects", &cur)) { @@ -557,6 +579,7 @@ fg_tiles[i].clear(); } + reset_points.clear(); name.clear(); author.clear(); theme.clear(); Index: gameloop.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/gameloop.cpp,v retrieving revision 1.81 retrieving revision 1.82 diff -u -d -r1.81 -r1.82 --- gameloop.cpp 19 Apr 2004 21:20:57 -0000 1.81 +++ gameloop.cpp 19 Apr 2004 22:47:36 -0000 1.82 @@ -63,6 +63,13 @@ fps_timer.init(true); frame_timer.init(true); + float old_x_pos = -1; + + if (world) + { // Tux has lost a life, so we try to respawn him at the nearest reset point + old_x_pos = world->get_tux()->base.x; + } + delete world; if (st_gl_mode == ST_GL_LOAD_LEVEL_FILE) @@ -77,6 +84,25 @@ { world = new World(subset, levelnb); } + + // Set Tux to the nearest reset point + if (old_x_pos != -1) + { + ResetPoint best_reset_point = { -1, -1 }; + for(std::vector<ResetPoint>::iterator i = get_level()->reset_points.begin(); + i != get_level()->reset_points.end(); ++i) + { + if (i->x < old_x_pos && best_reset_point.x < i->x) + best_reset_point = *i; + } + + if (best_reset_point.x != -1) + { + world->get_tux()->base.x = best_reset_point.x; + world->get_tux()->base.y = best_reset_point.y; + } + } + if (st_gl_mode != ST_GL_DEMO_GAME) { Index: level.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/level.h,v retrieving revision 1.32 retrieving revision 1.33 diff -u -d -r1.32 -r1.33 --- level.h 18 Apr 2004 22:36:03 -0000 1.32 +++ level.h 19 Apr 2004 22:47:36 -0000 1.33 @@ -50,6 +50,12 @@ TM_FG }; +struct ResetPoint +{ + int x; + int y; +}; + class Level { public: @@ -74,6 +80,9 @@ float gravity; std::vector<BadGuyData> badguy_data; + + /** A collection of points to which Tux can be reset after a lost live */ + std::vector<ResetPoint> reset_points; public: Level(); Level(const std::string& subset, int level); |
From: Ingo R. <gr...@us...> - 2004-04-19 21:54:43
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21341 Modified Files: menu.cpp menu.h Log Message: - cleaned up my last_menu patch a bit more Index: menu.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/menu.cpp,v retrieving revision 1.39 retrieving revision 1.40 diff -u -d -r1.39 -r1.40 --- menu.cpp 19 Apr 2004 21:21:00 -0000 1.39 +++ menu.cpp 19 Apr 2004 21:54:34 -0000 1.40 @@ -59,15 +59,33 @@ Menu* Menu::current_ = 0; void -Menu::set_current(Menu* menu) +Menu::push_current(Menu* pmenu) { - if (menu) - { - if (last_menus.empty() || menu != last_menus.top()) - last_menus.push(current_); + if (current_) + last_menus.push(current_); + + set_current(pmenu); +} - menu->effect.start(500); +void +Menu::pop_current() +{ + if (!last_menus.empty()) + { + set_current(last_menus.top()); + last_menus.pop(); } + else + { + set_current(0); + } +} + +void +Menu::set_current(Menu* menu) +{ + if (menu) + menu->effect.start(500); current_ = menu; } @@ -234,7 +252,7 @@ { case MN_GOTO: if (item[active_item].target_menu != NULL) - Menu::set_current(item[active_item].target_menu); + Menu::push_current(item[active_item].target_menu); else puts("NULLL"); break; @@ -251,11 +269,7 @@ break; case MN_BACK: - if (!last_menus.empty()) - { - Menu::set_current(last_menus.top()); - last_menus.pop(); - } + Menu::pop_current(); break; default: break; @@ -591,16 +605,8 @@ delete_character++; break; case SDLK_ESCAPE: - if(Menu::current()) - { - if (has_backitem == true && !last_menus.empty()) - { - Menu::set_current(last_menus.top()); - last_menus.pop(); - } - else - Menu::set_current(0); - } + Menu::pop_current(); + break; default: if( (key >= SDLK_0 && key <= SDLK_9) || (key >= SDLK_a && key <= SDLK_z) || (key >= SDLK_SPACE && key <= SDLK_SLASH)) { Index: menu.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/menu.h,v retrieving revision 1.38 retrieving revision 1.39 diff -u -d -r1.38 -r1.39 --- menu.h 19 Apr 2004 21:21:00 -0000 1.38 +++ menu.h 19 Apr 2004 21:54:34 -0000 1.39 @@ -66,6 +66,9 @@ private: static std::stack<Menu*> last_menus; static Menu* current_; + + static void push_current(Menu* pmenu); + static void pop_current(); public: /** Set the current menu, if pmenu is NULL, hide the current menu */ static void set_current(Menu* pmenu); |
From: Ingo R. <gr...@us...> - 2004-04-19 21:21:13
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13812 Modified Files: gameloop.cpp menu.cpp menu.h supertux.cpp title.cpp title.h worldmap.cpp Log Message: - fixed problem with last_menu not being able to handle menues deeper than two submenues - misc other cleanup Index: menu.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/menu.cpp,v retrieving revision 1.38 retrieving revision 1.39 diff -u -d -r1.38 -r1.39 --- menu.cpp 19 Apr 2004 19:22:27 -0000 1.38 +++ menu.cpp 19 Apr 2004 21:21:00 -0000 1.39 @@ -1,20 +1,28 @@ -/* - menu.c - - Super Tux - Menu - - by Tobias Glaesser - tob...@gm... - http://www.newbreedsoftware.com/supertux/ - - December 20, 2003 - March 15, 2004 -*/ +// $Id$ +// +// SuperTux +// Copyright (C) 2004 Tobias Glaesser <tob...@gm...> +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #ifndef WIN32 #include <sys/types.h> #include <ctype.h> #endif +#include <iostream> #include <stdlib.h> #include <stdio.h> #include <string.h> @@ -47,6 +55,7 @@ Menu* contrib_menu = 0; Menu* contrib_subset_menu = 0; +std::stack<Menu*> Menu::last_menus; Menu* Menu::current_ = 0; void @@ -54,7 +63,9 @@ { if (menu) { - menu->last_menu = current_; + if (last_menus.empty() || menu != last_menus.top()) + last_menus.push(current_); + menu->effect.start(500); } @@ -136,10 +147,8 @@ pos_x = screen->w/2; pos_y = screen->h/2; has_backitem = false; - last_menu = 0; arrange_left = 0; active_item = 0; - last_menu = 0; effect.init(false); } @@ -242,8 +251,11 @@ break; case MN_BACK: - if(last_menu != NULL) - Menu::set_current(last_menu); + if (!last_menus.empty()) + { + Menu::set_current(last_menus.top()); + last_menus.pop(); + } break; default: break; @@ -581,8 +593,11 @@ case SDLK_ESCAPE: if(Menu::current()) { - if (has_backitem == true && last_menu != NULL) - Menu::set_current(last_menu); + if (has_backitem == true && !last_menus.empty()) + { + Menu::set_current(last_menus.top()); + last_menus.pop(); + } else Menu::set_current(0); } Index: menu.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/menu.h,v retrieving revision 1.37 retrieving revision 1.38 diff -u -d -r1.37 -r1.38 --- menu.h 19 Apr 2004 19:22:27 -0000 1.37 +++ menu.h 19 Apr 2004 21:21:00 -0000 1.38 @@ -1,20 +1,28 @@ -/* - menu.h - - Super Tux - Menu - - by Tobias Glaesser - tob...@gm... - http://www.newbreedsoftware.com/supertux/ - - December 20, 2003 -*/ +// $Id$ +// +// SuperTux +// Copyright (C) 2004 Tobias Glaesser <tob...@gm...> +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #ifndef SUPERTUX_MENU_H #define SUPERTUX_MENU_H #include <SDL.h> #include <vector> +#include <stack> #include "texture.h" #include "timer.h" #include "type.h" @@ -55,6 +63,16 @@ class Menu { +private: + static std::stack<Menu*> last_menus; + static Menu* current_; +public: + /** Set the current menu, if pmenu is NULL, hide the current menu */ + static void set_current(Menu* pmenu); + + /** Return the current active menu or NULL if none is active */ + static Menu* current() { return current_; } + private: /* Action done on the menu */ enum MenuAction { @@ -73,27 +91,22 @@ int pos_y; bool has_backitem; - /** input event for the menu */ + /** input event for the menu (up, down, left, right, etc.) */ MenuAction menuaction; /* input implementation variables */ int delete_character; char mn_input_char; - Menu* last_menu; int width(); int height(); - - static Menu* current_; + public: Timer effect; int arrange_left; int active_item; - std::vector<MenuItem> item; - /** Set the current menu, if pmenu is NULL, hide the current menu */ - static void set_current(Menu* pmenu); - static Menu* current() { return current_; } + std::vector<MenuItem> item; Menu(); ~Menu(); @@ -105,8 +118,11 @@ /** Remove all entries from the menu */ void clear(); - /** Check, if the value of the active menu item has changed. */ + /** Check, if the value of the active menu item has changed. FIXME: + Somebody should document the exact meaning of this function a + bit more */ int check (); + void draw (); void draw_item(int index, int menu_width, int menu_height); void set_pos(int x, int y, float rw = 0, float rh = 0); Index: title.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/title.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- title.h 11 Apr 2004 01:24:58 -0000 1.3 +++ title.h 19 Apr 2004 21:21:00 -0000 1.4 @@ -10,4 +10,4 @@ April 11, 2000 - March 15, 2004 */ -bool title(void); +void title(void); Index: title.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/title.cpp,v retrieving revision 1.47 retrieving revision 1.48 diff -u -d -r1.47 -r1.48 --- title.cpp 19 Apr 2004 19:22:27 -0000 1.47 +++ title.cpp 19 Apr 2004 21:21:00 -0000 1.48 @@ -49,8 +49,6 @@ static bool walking; static Timer random_timer; -static SDL_Event event; -static SDLKey key; static int frame, i; static unsigned int last_update_time; static unsigned int update_time; @@ -217,7 +215,7 @@ } /* --- TITLE SCREEN --- */ -bool title(void) +void title(void) { st_subset subset; random_timer.init(true); @@ -232,24 +230,21 @@ updatescreen(); /* Load images: */ - bkg_title = new Surface(datadir + "/images/title/background.jpg", IGNORE_ALPHA); logo = new Surface(datadir + "/images/title/logo.png", USE_ALPHA); img_choose_subset = new Surface(datadir + "/images/status/choose-level-subset.png", USE_ALPHA); /* --- Main title loop: --- */ - bool done = 0; frame = 0; /* Draw the title background: */ bkg_title->draw_bg(); - load_hs(); update_time = st_get_ticks(); random_timer.start(rand() % 2000 + 2000); Menu::set_current(main_menu); - while (!done) + while (Menu::current()) { // Calculate the movement-factor double frame_ratio = ((double)(update_time-last_update_time))/((double)FRAME_RATE); @@ -258,29 +253,18 @@ /* Lower the frame_ratio that Tux doesn't jump to hectically throught the demo. */ frame_ratio /= 2; - /* Handle events: */ - + SDL_Event event; while (SDL_PollEvent(&event)) { - if (event.type == SDL_QUIT) + if (Menu::current()) { - done = true; + Menu::current()->event(event); } - else if (event.type == SDL_KEYDOWN) + else { - /* Keypress... */ - key = event.key.keysym.sym; - - if (Menu::current()) - { - Menu::current()->event(event); - } - - if (!Menu::current()) - { - /* Escape: Quit: */ - done = true; - } + // FIXME: QUIT signal should be handled more generic, not locally + if (event.type == SDL_QUIT) + Menu::set_current(0); } } @@ -299,7 +283,7 @@ 0, 420, 0); /* Don't draw menu, if quit is true */ - if(!done) + if(Menu::current()) { Menu::current()->action(); Menu::current()->draw(); @@ -318,15 +302,15 @@ update_contrib_menu(); break; case 3: - done = true; - done = leveleditor(1); + leveleditor(1); Menu::set_current(main_menu); break; case 4: display_credits(); + Menu::set_current(main_menu); break; case 5: - done = true; + Menu::set_current(0); break; } } @@ -371,9 +355,6 @@ delete bkg_title; delete logo; - - /* Return to main! */ - return done; } #define MAX_VEL 10 @@ -427,6 +408,7 @@ while(done == 0) { /* in case of input, exit */ + SDL_Event event; while(SDL_PollEvent(&event)) switch(event.type) { Index: worldmap.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/worldmap.cpp,v retrieving revision 1.36 retrieving revision 1.37 diff -u -d -r1.36 -r1.37 --- worldmap.cpp 19 Apr 2004 19:22:27 -0000 1.36 +++ worldmap.cpp 19 Apr 2004 21:21:00 -0000 1.37 @@ -364,8 +364,7 @@ void WorldMap::on_escape_press() { - std::cout << "on escape press" << std::endl; - + // Show or hide the menu if(!Menu::current()) Menu::set_current(worldmap_menu); else Index: supertux.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/supertux.cpp,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- supertux.cpp 17 Apr 2004 00:49:54 -0000 1.11 +++ supertux.cpp 19 Apr 2004 21:21:00 -0000 1.12 @@ -27,8 +27,6 @@ int main(int argc, char * argv[]) { - bool done; - st_directory_setup(); parseargs(argc, argv); @@ -51,11 +49,7 @@ } else { - done = false; - while (!done) - { - done = title(); - } + title(); } clearscreen(0, 0, 0); Index: gameloop.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/gameloop.cpp,v retrieving revision 1.80 retrieving revision 1.81 diff -u -d -r1.80 -r1.81 --- gameloop.cpp 19 Apr 2004 19:22:26 -0000 1.80 +++ gameloop.cpp 19 Apr 2004 21:20:57 -0000 1.81 @@ -131,22 +131,14 @@ void GameSession::on_escape_press() { - if(!game_pause) + if(st_gl_mode == ST_GL_TEST) { - if(st_gl_mode == ST_GL_TEST) - { - exit_status = LEVEL_ABORT; - } - else if (!Menu::current()) - { - Menu::set_current(game_menu); - st_pause_ticks_stop(); - } - else - { - Menu::set_current(NULL); - st_pause_ticks_start(); - } + exit_status = LEVEL_ABORT; + } + else if (!Menu::current()) + { + Menu::set_current(game_menu); + st_pause_ticks_stop(); } } @@ -160,151 +152,153 @@ { /* Check for menu-events, if the menu is shown */ if (Menu::current()) - Menu::current()->event(event); - - switch(event.type) { - case SDL_QUIT: /* Quit event - quit: */ - st_abort("Received window close", ""); - break; - - case SDL_KEYDOWN: /* A keypress! */ - { - SDLKey key = event.key.keysym.sym; - - if(tux.key_event(key,DOWN)) + Menu::current()->event(event); + } + else + { + switch(event.type) + { + case SDL_QUIT: /* Quit event - quit: */ + st_abort("Received window close", ""); break; - switch(key) + case SDL_KEYDOWN: /* A keypress! */ { - case SDLK_ESCAPE: /* Escape: Open/Close the menu: */ - on_escape_press(); - break; - default: - break; - } - } - break; - case SDL_KEYUP: /* A keyrelease! */ - { - SDLKey key = event.key.keysym.sym; + SDLKey key = event.key.keysym.sym; + + if(tux.key_event(key,DOWN)) + break; - if(tux.key_event(key, UP)) + switch(key) + { + case SDLK_ESCAPE: /* Escape: Open/Close the menu: */ + on_escape_press(); + break; + default: + break; + } + } break; - - switch(key) + case SDL_KEYUP: /* A keyrelease! */ { - case SDLK_p: - if(!Menu::current()) + SDLKey key = event.key.keysym.sym; + + if(tux.key_event(key, UP)) + break; + + switch(key) { - if(game_pause) - { - game_pause = false; - st_pause_ticks_stop(); - } - else + case SDLK_p: + if(!Menu::current()) { - game_pause = true; - st_pause_ticks_start(); + if(game_pause) + { + game_pause = false; + st_pause_ticks_stop(); + } + else + { + game_pause = true; + st_pause_ticks_start(); + } } - } - break; - case SDLK_TAB: - if(debug_mode) - { - tux.size = !tux.size; - if(tux.size == BIG) + break; + case SDLK_TAB: + if(debug_mode) { - tux.base.height = 64; + tux.size = !tux.size; + if(tux.size == BIG) + { + tux.base.height = 64; + } + else + tux.base.height = 32; } + break; + case SDLK_END: + if(debug_mode) + player_status.distros += 50; + break; + case SDLK_DELETE: + if(debug_mode) + tux.got_coffee = 1; + break; + case SDLK_INSERT: + if(debug_mode) + tux.invincible_timer.start(TUX_INVINCIBLE_TIME); + break; + case SDLK_l: + if(debug_mode) + --player_status.lives; + break; + case SDLK_s: + if(debug_mode) + player_status.score += 1000; + case SDLK_f: + if(debug_fps) + debug_fps = false; else - tux.base.height = 32; + debug_fps = true; + break; + default: + break; } - break; - case SDLK_END: - if(debug_mode) - player_status.distros += 50; - break; - case SDLK_DELETE: - if(debug_mode) - tux.got_coffee = 1; - break; - case SDLK_INSERT: - if(debug_mode) - tux.invincible_timer.start(TUX_INVINCIBLE_TIME); - break; - case SDLK_l: - if(debug_mode) - --player_status.lives; - break; - case SDLK_s: - if(debug_mode) - player_status.score += 1000; - case SDLK_f: - if(debug_fps) - debug_fps = false; - else - debug_fps = true; - break; - default: - break; } - } - break; + break; - case SDL_JOYAXISMOTION: - switch(event.jaxis.axis) - { - case JOY_X: - if (event.jaxis.value < -JOYSTICK_DEAD_ZONE) - { - tux.input.left = DOWN; - tux.input.right = UP; - } - else if (event.jaxis.value > JOYSTICK_DEAD_ZONE) - { - tux.input.left = UP; - tux.input.right = DOWN; - } - else + case SDL_JOYAXISMOTION: + switch(event.jaxis.axis) { - tux.input.left = DOWN; - tux.input.right = DOWN; + case JOY_X: + if (event.jaxis.value < -JOYSTICK_DEAD_ZONE) + { + tux.input.left = DOWN; + tux.input.right = UP; + } + else if (event.jaxis.value > JOYSTICK_DEAD_ZONE) + { + tux.input.left = UP; + tux.input.right = DOWN; + } + else + { + tux.input.left = DOWN; + tux.input.right = DOWN; + } + break; + case JOY_Y: + if (event.jaxis.value > JOYSTICK_DEAD_ZONE) + tux.input.down = DOWN; + else if (event.jaxis.value < -JOYSTICK_DEAD_ZONE) + tux.input.down = UP; + else + tux.input.down = UP; + + break; + default: + break; } break; - case JOY_Y: - if (event.jaxis.value > JOYSTICK_DEAD_ZONE) - tux.input.down = DOWN; - else if (event.jaxis.value < -JOYSTICK_DEAD_ZONE) - tux.input.down = UP; - else - tux.input.down = UP; - - break; - default: + case SDL_JOYBUTTONDOWN: + if (event.jbutton.button == JOY_A) + tux.input.up = DOWN; + else if (event.jbutton.button == JOY_B) + tux.input.fire = DOWN; + else if (event.jbutton.button == JOY_START) + on_escape_press(); + break; + case SDL_JOYBUTTONUP: + if (event.jbutton.button == JOY_A) + tux.input.up = UP; + else if (event.jbutton.button == JOY_B) + tux.input.fire = UP; break; - } - break; - case SDL_JOYBUTTONDOWN: - if (event.jbutton.button == JOY_A) - tux.input.up = DOWN; - else if (event.jbutton.button == JOY_B) - tux.input.fire = DOWN; - else if (event.jbutton.button == JOY_START) - on_escape_press(); - break; - case SDL_JOYBUTTONUP: - if (event.jbutton.button == JOY_A) - tux.input.up = UP; - else if (event.jbutton.button == JOY_B) - tux.input.fire = UP; - break; - - default: - break; - - } /* switch */ + default: + break; + } /* switch */ + } } /* while */ } @@ -331,14 +325,6 @@ { // No more lives!? if(st_gl_mode != ST_GL_TEST) drawendscreen(); - - if(st_gl_mode != ST_GL_TEST) - { - // FIXME: highscore soving doesn't make sense in its - // current form - //if (player_status.score > hs_score) - //save_hs(player_status.score); - } exit_status = GAME_OVER; } @@ -572,13 +558,7 @@ white_text->draw("SCORE", 0, 0, 1); gold_text->draw(str, 96, 0, 1); - if(st_gl_mode != ST_GL_TEST) - { - sprintf(str, "%d", hs_score); - white_text->draw("HIGH", 0, 20, 1); - gold_text->draw(str, 96, 20, 1); - } - else + if(st_gl_mode == ST_GL_TEST) { white_text->draw("Press ESC To Return",0,20,1); } |
From: Ingo R. <gr...@us...> - 2004-04-19 19:22:43
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20529 Modified Files: gameloop.cpp high_scores.cpp leveleditor.cpp menu.cpp menu.h title.cpp worldmap.cpp Log Message: - removed menu_process_current() Index: menu.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/menu.cpp,v retrieving revision 1.37 retrieving revision 1.38 diff -u -d -r1.37 -r1.38 --- menu.cpp 19 Apr 2004 19:06:44 -0000 1.37 +++ menu.cpp 19 Apr 2004 19:22:27 -0000 1.38 @@ -523,17 +523,6 @@ } } -/* --- MENU --- */ -/* Draw the current menu and execute the (menu)events */ -void menu_process_current() -{ - if(Menu::current()) - { - Menu::current()->action(); - Menu::current()->draw(); - } -} - /* Check for menu event */ void Menu::event(SDL_Event& event) Index: menu.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/menu.h,v retrieving revision 1.36 retrieving revision 1.37 diff -u -d -r1.36 -r1.37 --- menu.h 19 Apr 2004 19:06:45 -0000 1.36 +++ menu.h 19 Apr 2004 19:22:27 -0000 1.37 @@ -132,9 +132,6 @@ extern Menu* load_game_menu; extern Menu* save_game_menu; -/* "Calculate" and draw the menu */ -void menu_process_current(void); - #endif /*SUPERTUX_MENU_H*/ /* Local Variables: */ Index: leveleditor.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/leveleditor.cpp,v retrieving revision 1.53 retrieving revision 1.54 diff -u -d -r1.53 -r1.54 --- leveleditor.cpp 19 Apr 2004 19:06:44 -0000 1.53 +++ leveleditor.cpp 19 Apr 2004 19:22:27 -0000 1.54 @@ -210,7 +210,9 @@ if(Menu::current()) { - menu_process_current(); + Menu::current()->action(); + Menu::current()->draw(); + if(Menu::current() == leveleditor_menu) { switch (leveleditor_menu->check()) Index: title.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/title.cpp,v retrieving revision 1.46 retrieving revision 1.47 diff -u -d -r1.46 -r1.47 --- title.cpp 19 Apr 2004 19:06:45 -0000 1.46 +++ title.cpp 19 Apr 2004 19:22:27 -0000 1.47 @@ -300,7 +300,10 @@ /* Don't draw menu, if quit is true */ if(!done) - menu_process_current(); + { + Menu::current()->action(); + Menu::current()->draw(); + } if(Menu::current() == main_menu) { Index: worldmap.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/worldmap.cpp,v retrieving revision 1.35 retrieving revision 1.36 diff -u -d -r1.35 -r1.36 --- worldmap.cpp 19 Apr 2004 19:06:45 -0000 1.35 +++ worldmap.cpp 19 Apr 2004 19:22:27 -0000 1.36 @@ -708,7 +708,8 @@ if(Menu::current()) { - menu_process_current(); + Menu::current()->action(); + Menu::current()->draw(); mouse_cursor->draw(); } flipscreen(); Index: high_scores.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/high_scores.cpp,v retrieving revision 1.13 retrieving revision 1.14 diff -u -d -r1.13 -r1.14 --- high_scores.cpp 19 Apr 2004 19:06:44 -0000 1.13 +++ high_scores.cpp 19 Apr 2004 19:22:27 -0000 1.14 @@ -94,7 +94,9 @@ sprintf(str, "%d", hs_score); yellow_nums->draw(str, 350, 170, 1, NO_UPDATE); - menu_process_current(); + Menu::current()->action(); + Menu::current()->draw(); + flipscreen(); while(SDL_PollEvent(&event)) Index: gameloop.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/gameloop.cpp,v retrieving revision 1.79 retrieving revision 1.80 diff -u -d -r1.79 -r1.80 --- gameloop.cpp 19 Apr 2004 19:06:44 -0000 1.79 +++ gameloop.cpp 19 Apr 2004 19:22:26 -0000 1.80 @@ -381,7 +381,8 @@ if(Menu::current()) { - menu_process_current(); + Menu::current()->action(); + Menu::current()->draw(); mouse_cursor->draw(); } |
From: Ricardo C. <rm...@us...> - 2004-04-19 14:34:54
|
Update of /cvsroot/super-tux/supertux/data/music In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23717/data/music Modified Files: cave-fast.mod cave.mod fortress-fast.mod fortress.mod Log Message: Marek update for his musics. Index: cave-fast.mod =================================================================== RCS file: /cvsroot/super-tux/supertux/data/music/cave-fast.mod,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 Binary files /tmp/cvs3zq8fI and /tmp/cvsKulMWd differ Index: fortress-fast.mod =================================================================== RCS file: /cvsroot/super-tux/supertux/data/music/fortress-fast.mod,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 Binary files /tmp/cvsMH4I8Y and /tmp/cvsB59oiv differ Index: fortress.mod =================================================================== RCS file: /cvsroot/super-tux/supertux/data/music/fortress.mod,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 Binary files /tmp/cvsuSmgEz and /tmp/cvsHazg65 differ Index: cave.mod =================================================================== RCS file: /cvsroot/super-tux/supertux/data/music/cave.mod,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 Binary files /tmp/cvs6ujoXa and /tmp/cvsyudzMH differ |