[Super-tux-commit] supertux/src player.cpp,1.117,1.118 player.h,1.59,1.60
Brought to you by:
wkendrick
From: Ricardo C. <rm...@us...> - 2004-05-23 00:12:07
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8984/src Modified Files: player.cpp player.h Log Message: Made butt-jump to behave according to what Marek asked. You can tune a definition... Now, we just need a butt-jump image. Index: player.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/player.cpp,v retrieving revision 1.117 retrieving revision 1.118 diff -u -d -r1.117 -r1.118 --- player.cpp 22 May 2004 15:27:40 -0000 1.117 +++ player.cpp 23 May 2004 00:11:58 -0000 1.118 @@ -29,9 +29,12 @@ #include "sprite.h" #include "screen.h" -#define AUTOSCROLL_DEAD_INTERVAL 300 +// behavior definitions: +#define TILES_FOR_BUTTJUMP 3 // animation times (in ms): #define SHOOTING_TIME 320 +// others stuff: +#define AUTOSCROLL_DEAD_INTERVAL 300 Surface* tux_life; @@ -310,6 +313,19 @@ issolid(base.x + base.width - 1, base.y) ); } +bool +Player::tiles_on_air(int tiles) +{ + for(int t = 0; t != tiles; t++) + { + if(issolid(base.x + base.width / 2, base.y + base.height + (tiles*32)) || + issolid(base.x + 1, base.y + base.height + (tiles*32)) || + issolid(base.x + base.width - 1, base.y + base.height + (tiles*32))) + return false; + } + return true; +} + void Player::handle_horizontal_input() { @@ -415,7 +431,6 @@ --base.y; jumping = true; can_jump = false; - butt_jump = true; // player started jumping, enable butt jump if (size == SMALL) play_sound(sounds[SND_JUMP], SOUND_CENTER_SPEAKER); else @@ -426,15 +441,19 @@ { jumping = false; physic.set_velocity_y(0); - butt_jump = false; // jump was not full, disable butt jump } - /* Do butt jump, in case the player has done the combination - (full jump and hold DOWN) */ - if (input.down == UP && physic.get_velocity_y() == World::current()->get_level()->gravity && butt_jump) - butt_jump = false; // in case DOWN is not hold after the full jump, disable it - - if (input.down == DOWN && butt_jump && on_ground() && size == BIG) + /* In case the player has pressed Down while in a certain range of air, + enable butt jump action */ + if (input.down == DOWN && !butt_jump) + if(tiles_on_air(TILES_FOR_BUTTJUMP)) + butt_jump = true; + + /* When Down is not held anymore, disable butt jump */ + if(butt_jump && input.down == UP) + butt_jump = false; + + if (butt_jump && on_ground() && size == BIG) { if(World::current()->trybreakbrick(base.x, base.y + base.height, false) || World::current()->trybreakbrick( @@ -442,7 +461,7 @@ // make tux jumping a little bit again after breaking the bricks physic.set_velocity_y(2); } -// butt_jump = false; +// butt_jump = false; // comment this, in case you won't to disable the continued use of buttjump } if ( (issolid(base.x + base.width / 2, base.y + base.height + 64) || Index: player.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/player.h,v retrieving revision 1.59 retrieving revision 1.60 diff -u -d -r1.59 -r1.60 --- player.h 22 May 2004 15:27:45 -0000 1.59 +++ player.h 23 May 2004 00:11:58 -0000 1.60 @@ -162,6 +162,7 @@ void check_bounds(ViewPort& viewport, bool back_scrolling, bool hor_autoscroll); bool on_ground(); bool under_solid(); + bool tiles_on_air(int tiles); void grow(); private: |