[Super-tux-commit] supertux/src badguy.cpp,1.38,1.39 badguy.h,1.27,1.28 physic.cpp,1.11,1.12
Brought to you by:
wkendrick
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; } |