[Super-tux-commit] supertux/src badguy.cpp,1.26,1.27 badguy.h,1.21,1.22 gameloop.cpp,1.59,1.60 gamel
Brought to you by:
wkendrick
From: Ingo R. <gr...@us...> - 2004-04-11 15:42:23
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv726 Modified Files: badguy.cpp badguy.h gameloop.cpp gameloop.h gameobjs.cpp gameobjs.h physic.cpp physic.h player.cpp player.h scene.cpp scene.h special.cpp special.h title.cpp world.cpp world.h Log Message: - made frame ration local Index: scene.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/scene.cpp,v retrieving revision 1.18 retrieving revision 1.19 diff -u -d -r1.18 -r1.19 --- scene.cpp 11 Apr 2004 15:07:29 -0000 1.18 +++ scene.cpp 11 Apr 2004 15:28:26 -0000 1.19 @@ -21,7 +21,6 @@ unsigned int global_frame_counter; timer_type time_left; -double frame_ratio; // EOF // Index: world.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/world.h,v retrieving revision 1.20 retrieving revision 1.21 diff -u -d -r1.20 -r1.21 --- world.h 11 Apr 2004 14:55:59 -0000 1.20 +++ world.h 11 Apr 2004 15:28:26 -0000 1.21 @@ -67,7 +67,7 @@ void set_defaults(); void draw(); - void action(); + void action(double frame_ratio); /** Checks for all possible collisions. And calls the collision_handlers, which the collision_objects provide for this Index: special.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/special.cpp,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- special.cpp 11 Apr 2004 15:07:29 -0000 1.12 +++ special.cpp 11 Apr 2004 15:28:26 -0000 1.13 @@ -53,7 +53,7 @@ } void -Bullet::action() +Bullet::action(double frame_ratio) { base.x = base.x + base.xm * frame_ratio; base.y = base.y + base.ym * frame_ratio; @@ -128,7 +128,7 @@ } void -Upgrade::action() +Upgrade::action(double frame_ratio) { if (base.height < 32) { Index: badguy.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/badguy.cpp,v retrieving revision 1.26 retrieving revision 1.27 diff -u -d -r1.26 -r1.27 --- badguy.cpp 11 Apr 2004 15:07:29 -0000 1.26 +++ badguy.cpp 11 Apr 2004 15:28:26 -0000 1.27 @@ -198,7 +198,7 @@ } void -BadGuy::action_bsod() +BadGuy::action_bsod(float frame_ratio) { static const float BSODJUMP = 2; @@ -223,13 +223,13 @@ } // move - physic.apply(base.x, base.y); + physic.apply(frame_ratio, base.x, base.y); if(dying != DYING_FALLING) collision_swept_object_map(&old_base, &base); } void -BadGuy::action_laptop() +BadGuy::action_laptop(float frame_ratio) { Player& tux = *World::current()->get_tux(); @@ -239,7 +239,7 @@ if (mode == NORMAL || mode == KICK) { // move - physic.apply(base.x, base.y); + physic.apply(frame_ratio, base.x, base.y); if (dying != DYING_FALLING) collision_swept_object_map(&old_base,&base); } @@ -386,7 +386,7 @@ } void -BadGuy::action_money() +BadGuy::action_money(float frame_ratio) { Player& tux = *World::current()->get_tux(); @@ -414,26 +414,26 @@ dir = LEFT; // move - physic.apply(base.x, base.y); + physic.apply(frame_ratio, base.x, base.y); if(dying == DYING_NOT) collision_swept_object_map(&old_base, &base); } void -BadGuy::action_mrbomb() +BadGuy::action_mrbomb(float frame_ratio) { if (dying == DYING_NOT) check_horizontal_bump(true); fall(); - physic.apply(base.x, base.y); + physic.apply(frame_ratio, base.x, base.y); if (dying != DYING_FALLING) collision_swept_object_map(&old_base,&base); } void -BadGuy::action_bomb() +BadGuy::action_bomb(float frame_ratio) { static const int TICKINGTIME = 1000; static const int EXPLODETIME = 1000; @@ -456,12 +456,12 @@ } // move - physic.apply(base.x, base.y); + physic.apply(frame_ratio, base.x, base.y); collision_swept_object_map(&old_base,&base); } void -BadGuy::action_stalactite() +BadGuy::action_stalactite(float frame_ratio) { Player& tux = *World::current()->get_tux(); @@ -496,14 +496,14 @@ } // move - physic.apply(base.x, base.y); + physic.apply(frame_ratio, base.x, base.y); if(dying == DYING_SQUISHED && !timer_check(&timer)) remove_me(); } void -BadGuy::action_flame() +BadGuy::action_flame(float frame_ratio) { static const float radius = 100; static const float speed = 0.02; @@ -514,7 +514,7 @@ } void -BadGuy::action_fish() +BadGuy::action_fish(float frame_ratio) { static const float JUMPV = 6; static const int WAITTIME = 1000; @@ -539,13 +539,13 @@ physic.enable_gravity(true); } - physic.apply(base.x, base.y); + physic.apply(frame_ratio, base.x, base.y); if(dying == DYING_NOT) collision_swept_object_map(&old_base, &base); } void -BadGuy::action_bouncingsnowball() +BadGuy::action_bouncingsnowball(float frame_ratio) { static const float JUMPV = 4.5; @@ -565,7 +565,7 @@ // check for right/left collisions check_horizontal_bump(); - physic.apply(base.x, base.y); + physic.apply(frame_ratio, base.x, base.y); if(dying == DYING_NOT) collision_swept_object_map(&old_base, &base); @@ -579,7 +579,7 @@ } void -BadGuy::action_flyingsnowball() +BadGuy::action_flyingsnowball(float frame_ratio) { static const float FLYINGSPEED = 1; static const int DIRCHANGETIME = 1000; @@ -605,7 +605,7 @@ if(dying != DYING_NOT) physic.enable_gravity(true); - physic.apply(base.x, base.y); + physic.apply(frame_ratio, base.x, base.y); if(dying == DYING_NOT || dying == DYING_SQUISHED) collision_swept_object_map(&old_base, &base); @@ -619,7 +619,7 @@ } void -BadGuy::action_spiky() +BadGuy::action_spiky(float frame_ratio) { if (dying == DYING_NOT) check_horizontal_bump(); @@ -634,26 +634,26 @@ } #endif - physic.apply(base.x, base.y); + physic.apply(frame_ratio, base.x, base.y); if (dying != DYING_FALLING) collision_swept_object_map(&old_base,&base); } void -BadGuy::action_snowball() +BadGuy::action_snowball(float frame_ratio) { if (dying == DYING_NOT) check_horizontal_bump(); fall(); - physic.apply(base.x, base.y); + physic.apply(frame_ratio, base.x, base.y); if (dying != DYING_FALLING) collision_swept_object_map(&old_base,&base); } void -BadGuy::action() +BadGuy::action(float frame_ratio) { // Remove if it's far off the screen: if (base.x < scroll_x - OFFSCREEN_DISTANCE) @@ -678,51 +678,51 @@ switch (kind) { case BAD_BSOD: - action_bsod(); + action_bsod(frame_ratio); break; case BAD_LAPTOP: - action_laptop(); + action_laptop(frame_ratio); break; case BAD_MONEY: - action_money(); + action_money(frame_ratio); break; case BAD_MRBOMB: - action_mrbomb(); + action_mrbomb(frame_ratio); break; case BAD_BOMB: - action_bomb(); + action_bomb(frame_ratio); break; case BAD_STALACTITE: - action_stalactite(); + action_stalactite(frame_ratio); break; case BAD_FLAME: - action_flame(); + action_flame(frame_ratio); break; case BAD_FISH: - action_fish(); + action_fish(frame_ratio); break; case BAD_BOUNCINGSNOWBALL: - action_bouncingsnowball(); + action_bouncingsnowball(frame_ratio); break; case BAD_FLYINGSNOWBALL: - action_flyingsnowball(); + action_flyingsnowball(frame_ratio); break; case BAD_SPIKY: - action_spiky(); + action_spiky(frame_ratio); break; case BAD_SNOWBALL: - action_snowball(); + action_snowball(frame_ratio); break; } } Index: gameobjs.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/gameobjs.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- gameobjs.h 11 Apr 2004 12:43:35 -0000 1.3 +++ gameobjs.h 11 Apr 2004 15:28:26 -0000 1.4 @@ -35,7 +35,7 @@ base_type base; void init(float x, float y); - void action(); + void action(double frame_ratio); void draw(); }; @@ -54,7 +54,7 @@ Tile* tile; void init(Tile* tile, float x, float y, float xm, float ym); - void action(); + void action(double frame_ratio); void draw(); }; @@ -67,7 +67,7 @@ base_type base; void init(float x, float y); - void action(); + void action(double frame_ratio); void draw(); }; @@ -79,7 +79,7 @@ base_type base; void init(float x, float y, int s); - void action(); + void action(double frame_ratio); void draw(); }; Index: scene.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/scene.h,v retrieving revision 1.21 retrieving revision 1.22 diff -u -d -r1.21 -r1.22 --- scene.h 11 Apr 2004 15:07:29 -0000 1.21 +++ scene.h 11 Apr 2004 15:28:26 -0000 1.22 @@ -29,11 +29,9 @@ extern PlayerStatus player_status; -extern timer_type super_bkgd_timer; extern float scroll_x; extern unsigned int global_frame_counter; extern timer_type time_left; -extern double frame_ratio; #endif /*SUPERTUX_SCENE_H*/ Index: special.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/special.h,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- special.h 11 Apr 2004 13:20:43 -0000 1.11 +++ special.h 11 Apr 2004 15:28:26 -0000 1.12 @@ -39,7 +39,7 @@ base_type old_base; void init(float x, float y, int dir, int kind); - void action(); + void action(double frame_ratio); void draw(); void collision(void* p_c_object, int c_object); }; @@ -51,7 +51,7 @@ base_type old_base; void init(float x, float y, float xm, int dir); - void action(); + void action(double frame_ratio); void draw(); void collision(int c_object); }; Index: gameloop.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/gameloop.cpp,v retrieving revision 1.59 retrieving revision 1.60 diff -u -d -r1.59 -r1.60 --- gameloop.cpp 11 Apr 2004 15:07:29 -0000 1.59 +++ gameloop.cpp 11 Apr 2004 15:28:26 -0000 1.60 @@ -338,7 +338,7 @@ } int -GameSession::action() +GameSession::action(double frame_ratio) { Player& tux = *world->get_tux(); @@ -428,9 +428,9 @@ play_current_music(); } - tux.action(); + tux.action(frame_ratio); - world->action(); + world->action(frame_ratio); return -1; } @@ -496,7 +496,7 @@ while (!done && !quit) { /* Calculate the movement-factor */ - frame_ratio = ((double)(update_time-last_update_time))/((double)FRAME_RATE); + double frame_ratio = ((double)(update_time-last_update_time))/((double)FRAME_RATE); if(frame_ratio > 1.5) /* Quick hack to correct the unprecise CPU clocks a little bit. */ frame_ratio = 1.5 + (frame_ratio - 1.5) * 0.85; @@ -555,7 +555,7 @@ frame_ratio = 1; while(z >= 1) {*/ - if (action() == 0) + if (action(frame_ratio) == 0) { /* == 0: no more lives */ /* == -1: continues */ Index: gameloop.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/gameloop.h,v retrieving revision 1.35 retrieving revision 1.36 diff -u -d -r1.35 -r1.36 --- gameloop.h 11 Apr 2004 14:55:59 -0000 1.35 +++ gameloop.h 11 Apr 2004 15:28:26 -0000 1.36 @@ -62,7 +62,7 @@ int run(); void draw(); - int action(); + int action(double frame_ratio); Level* get_level() { return world->get_level(); } World* get_world() { return world; } Index: physic.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/physic.h,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- physic.h 11 Apr 2004 14:44:19 -0000 1.8 +++ physic.h 11 Apr 2004 15:28:26 -0000 1.9 @@ -43,7 +43,7 @@ void enable_gravity(bool gravity_enabled); /** applies the physical simulation to given x and y coordinates */ - void apply(float &x, float &y); + void apply(float frame_ratio, float &x, float &y); private: /// horizontal and vertical acceleration Index: physic.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/physic.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- physic.cpp 11 Apr 2004 14:44:19 -0000 1.6 +++ physic.cpp 11 Apr 2004 15:28:26 -0000 1.7 @@ -79,7 +79,7 @@ } void -Physic::apply(float &x, float &y) +Physic::apply(float frame_ratio, float &x, float &y) { float gravity = World::current()->get_level()->gravity; float grav; Index: badguy.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/badguy.h,v retrieving revision 1.21 retrieving revision 1.22 diff -u -d -r1.21 -r1.22 --- badguy.h 10 Apr 2004 11:42:43 -0000 1.21 +++ badguy.h 11 Apr 2004 15:28:26 -0000 1.22 @@ -108,7 +108,7 @@ public: void init(float x, float y, BadGuyKind kind); - void action(); + void action(float frame_ratio); void draw(); void collision(void* p_c_object, int c_object, @@ -120,18 +120,18 @@ void kill_me(); private: - void action_bsod(); - void action_laptop(); - void action_money(); - void action_bomb(); - void action_mrbomb(); - void action_stalactite(); - void action_flame(); - void action_fish(); - void action_bouncingsnowball(); - void action_flyingsnowball(); - void action_spiky(); - void action_snowball(); + void action_bsod(float frame_ratio); + void action_laptop(float frame_ratio); + void action_money(float frame_ratio); + void action_bomb(float frame_ratio); + void action_mrbomb(float frame_ratio); + void action_stalactite(float frame_ratio); + void action_flame(float frame_ratio); + void action_fish(float frame_ratio); + void action_bouncingsnowball(float frame_ratio); + void action_flyingsnowball(float frame_ratio); + void action_spiky(float frame_ratio); + void action_snowball(float frame_ratio); /** handles falling down. disables gravity calculation when we're back on * ground */ Index: gameobjs.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/gameobjs.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- gameobjs.cpp 11 Apr 2004 13:05:35 -0000 1.4 +++ gameobjs.cpp 11 Apr 2004 15:28:26 -0000 1.5 @@ -31,7 +31,7 @@ } void -BouncyDistro::action() +BouncyDistro::action(double frame_ratio) { base.y = base.y + base.ym * frame_ratio; @@ -64,7 +64,7 @@ } void -BrokenBrick::action() +BrokenBrick::action(double frame_ratio) { base.x = base.x + base.xm * frame_ratio; base.y = base.y + base.ym * frame_ratio; @@ -103,10 +103,9 @@ } void -BouncyBrick::action() +BouncyBrick::action(double frame_ratio) { - offset = (offset + - offset_m * frame_ratio); + offset = (offset + offset_m * frame_ratio); /* Go back down? */ if (offset < -BOUNCY_BRICK_MAX_OFFSET) @@ -166,7 +165,7 @@ } void -FloatingScore::action() +FloatingScore::action(double frame_ratio) { base.y = base.y - 2 * frame_ratio; Index: player.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/player.cpp,v retrieving revision 1.27 retrieving revision 1.28 diff -u -d -r1.27 -r1.28 --- player.cpp 11 Apr 2004 15:07:29 -0000 1.27 +++ player.cpp 11 Apr 2004 15:28:26 -0000 1.28 @@ -157,7 +157,7 @@ } void -Player::action() +Player::action(double frame_ratio) { bool jumped_in_solid = false; @@ -169,7 +169,7 @@ /* Move tux: */ previous_base = base; - physic.apply(base.x, base.y); + physic.apply(frame_ratio, base.x, base.y); if (!dying) { Index: player.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/player.h,v retrieving revision 1.22 retrieving revision 1.23 diff -u -d -r1.22 -r1.23 --- player.h 11 Apr 2004 14:44:19 -0000 1.22 +++ player.h 11 Apr 2004 15:28:26 -0000 1.23 @@ -121,7 +121,7 @@ void init(); int key_event(SDLKey key, int state); void level_begin(); - void action(); + void action(double frame_ratio); void handle_input(); void grabdistros(); void draw(); Index: title.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/title.cpp,v retrieving revision 1.30 retrieving revision 1.31 diff -u -d -r1.30 -r1.31 --- title.cpp 11 Apr 2004 14:44:19 -0000 1.30 +++ title.cpp 11 Apr 2004 15:28:26 -0000 1.31 @@ -63,7 +63,7 @@ texture_draw_bg(&bkg_title); } -void draw_demo(GameSession* session) +void draw_demo(GameSession* session, double frame_ratio) { World::set_current(session->get_world()); //World* world = session->get_world(); @@ -118,8 +118,10 @@ scroll_x = tux->base.x - 320; } + + float last_tux_x_pos = tux->base.x; - tux->action(); + tux->action(frame_ratio); // Jump if tux stays in the same position for one loop, ie. if he is // stuck behind a wall @@ -176,7 +178,7 @@ while (!done) { /* Calculate the movement-factor */ - frame_ratio = ((double)(update_time-last_update_time))/((double)FRAME_RATE); + double frame_ratio = ((double)(update_time-last_update_time))/((double)FRAME_RATE); if(frame_ratio > 1.5) /* Quick hack to correct the unprecise CPU clocks a little bit. */ frame_ratio = 1.5 + (frame_ratio - 1.5) * 0.85; /* Lower the frame_ratio that Tux doesn't jump to hectically throught the demo. */ @@ -209,7 +211,7 @@ /* Draw the background: */ draw_background(); - draw_demo(&session); + draw_demo(&session, frame_ratio); if (current_menu == main_menu) texture_draw(&logo, 160, 30); Index: world.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/world.cpp,v retrieving revision 1.19 retrieving revision 1.20 diff -u -d -r1.19 -r1.20 --- world.cpp 11 Apr 2004 15:07:29 -0000 1.19 +++ world.cpp 11 Apr 2004 15:28:26 -0000 1.20 @@ -208,15 +208,15 @@ } void -World::action() +World::action(double frame_ratio) { /* Handle bouncy distros: */ for (unsigned int i = 0; i < bouncy_distros.size(); i++) - bouncy_distros[i].action(); + bouncy_distros[i].action(frame_ratio); /* Handle broken bricks: */ for (unsigned int i = 0; i < broken_bricks.size(); i++) - broken_bricks[i].action(); + broken_bricks[i].action(frame_ratio); /* Handle distro counting: */ if (counting_distros) @@ -229,19 +229,19 @@ // Handle all kinds of game objects for (unsigned int i = 0; i < bouncy_bricks.size(); i++) - bouncy_bricks[i].action(); + bouncy_bricks[i].action(frame_ratio); for (unsigned int i = 0; i < floating_scores.size(); i++) - floating_scores[i].action(); + floating_scores[i].action(frame_ratio); for (unsigned int i = 0; i < bullets.size(); ++i) - bullets[i].action(); + bullets[i].action(frame_ratio); for (unsigned int i = 0; i < upgrades.size(); i++) - upgrades[i].action(); + upgrades[i].action(frame_ratio); for (unsigned int i = 0; i < bad_guys.size(); i++) - bad_guys[i].action(); + bad_guys[i].action(frame_ratio); /* update particle systems */ std::vector<ParticleSystem*>::iterator p; |