}
void
-BadGuy::action_bsod()
+BadGuy::action_bsod(float frame_ratio)
{
static const float BSODJUMP = 2;
}
// 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();
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);
}
}
void
-BadGuy::action_money()
+BadGuy::action_money(float frame_ratio)
{
Player& tux = *World::current()->get_tux();
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;
}
// 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();
}
// 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;
}
void
-BadGuy::action_fish()
+BadGuy::action_fish(float frame_ratio)
{
static const float JUMPV = 6;
static const int WAITTIME = 1000;
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;
// 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);
}
void
-BadGuy::action_flyingsnowball()
+BadGuy::action_flyingsnowball(float frame_ratio)
{
static const float FLYINGSPEED = 1;
static const int DIRCHANGETIME = 1000;
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);
}
void
-BadGuy::action_spiky()
+BadGuy::action_spiky(float frame_ratio)
{
if (dying == DYING_NOT)
check_horizontal_bump();
}
#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)
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;
}
}
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,
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 */
}
int
-GameSession::action()
+GameSession::action(double frame_ratio)
{
Player& tux = *world->get_tux();
play_current_music();
}
- tux.action();
+ tux.action(frame_ratio);
- world->action();
+ world->action(frame_ratio);
return -1;
}
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;
frame_ratio = 1;
while(z >= 1)
{*/
- if (action() == 0)
+ if (action(frame_ratio) == 0)
{
/* == 0: no more lives */
/* == -1: continues */
int run();
void draw();
- int action();
+ int action(double frame_ratio);
Level* get_level() { return world->get_level(); }
World* get_world() { return world; }
}
void
-BouncyDistro::action()
+BouncyDistro::action(double frame_ratio)
{
base.y = base.y + base.ym * frame_ratio;
}
void
-BrokenBrick::action()
+BrokenBrick::action(double frame_ratio)
{
base.x = base.x + base.xm * frame_ratio;
base.y = base.y + base.ym * frame_ratio;
}
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)
}
void
-FloatingScore::action()
+FloatingScore::action(double frame_ratio)
{
base.y = base.y - 2 * frame_ratio;
base_type base;
void init(float x, float y);
- void action();
+ void action(double frame_ratio);
void draw();
};
Tile* tile;
void init(Tile* tile, float x, float y, float xm, float ym);
- void action();
+ void action(double frame_ratio);
void draw();
};
base_type base;
void init(float x, float y);
- void action();
+ void action(double frame_ratio);
void draw();
};
base_type base;
void init(float x, float y, int s);
- void action();
+ void action(double frame_ratio);
void draw();
};
}
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;
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
}
void
-Player::action()
+Player::action(double frame_ratio)
{
bool jumped_in_solid = false;
/* Move tux: */
previous_base = base;
- physic.apply(base.x, base.y);
+ physic.apply(frame_ratio, base.x, base.y);
if (!dying)
{
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();
unsigned int global_frame_counter;
timer_type time_left;
-double frame_ratio;
// EOF //
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*/
}
void
-Bullet::action()
+Bullet::action(double frame_ratio)
{
base.x = base.x + base.xm * frame_ratio;
base.y = base.y + base.ym * frame_ratio;
}
void
-Upgrade::action()
+Upgrade::action(double frame_ratio)
{
if (base.height < 32)
{
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);
};
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);
};
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();
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
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. */
/* Draw the background: */
draw_background();
- draw_demo(&session);
+ draw_demo(&session, frame_ratio);
if (current_menu == main_menu)
texture_draw(&logo, 160, 30);
}
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)
// 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;
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