Bug: since the Sprite does not respect the frames order, it may not animate correctly. I think the best fix is to make Player object to take care of that using Surfaces.
SVN-Revision: 1341
void
GameSession::action(double frame_ratio)
{
- if (exit_status == ES_NONE)
+ if (exit_status == ES_NONE && !world->get_tux()->growing_timer.check())
{
// Update Tux and the World
world->action(frame_ratio);
Sprite* smalltux_gameover;
Sprite* smalltux_star;
Sprite* largetux_star;
+Sprite* growingtux_left;
+Sprite* growingtux_right;
PlayerSprite smalltux;
PlayerSprite largetux;
frame_timer.init(true);
kick_timer.init(true);
shooting_timer.init(true);
+ growing_timer.init(true);
physic.reset();
}
skidding_timer.init(true);
safe_timer.init(true);
frame_timer.init(true);
+ growing_timer.init(true);
physic.reset();
}
}
void
-Player::grow()
+Player::grow(bool animate)
{
if(size == BIG)
return;
base.height = 64;
base.y -= 32;
+ if(animate)
+ growing_timer.start((int)((growingtux_left->get_frames() / growingtux_left->get_fps()) * 1000));
+
old_base = previous_base = base;
}
}
else
{
- if (duck && size != SMALL)
+ if(growing_timer.check())
+ {
+ if (dir == RIGHT)
+ growingtux_right->draw(pos);
+ else
+ growingtux_left->draw(pos);
+ }
+ else if (duck && size != SMALL)
{
if (dir == RIGHT)
sprite->duck_right->draw(pos);
extern Sprite* smalltux_gameover;
extern Sprite* smalltux_star;
extern Sprite* largetux_star;
+extern Sprite* growingtux_left;
+extern Sprite* growingtux_right;
struct PlayerSprite
{
Timer kick_timer;
Timer shooting_timer; // used to show the arm when Tux is shooting
Timer dying_timer;
+ Timer growing_timer;
Physic physic;
public:
bool on_ground();
bool under_solid();
bool tiles_on_air(int tiles);
- void grow();
+ void grow(bool animate);
void move(const Vector& vector);
bool is_dead() const
{ return dead; }
largetux_star = sprite_manager->load("largetux-star");
smalltux_gameover = sprite_manager->load("smalltux-gameover");
+ growingtux_left = sprite_manager->load("tux-grow-left");
+ growingtux_right = sprite_manager->load("tux-grow-right");
+
smalltux.stand_left = sprite_manager->load("smalltux-stand-left");
smalltux.stand_right = sprite_manager->load("smalltux-stand-right");
smalltux.walk_left = sprite_manager->load("smalltux-walk-left");
if (kind == UPGRADE_GROWUP)
{
play_sound(sounds[SND_EXCELLENT], SOUND_CENTER_SPEAKER);
- pplayer->grow();
+ pplayer->grow(true);
}
else if (kind == UPGRADE_FIREFLOWER)
{
play_sound(sounds[SND_COFFEE], SOUND_CENTER_SPEAKER);
- pplayer->grow();
+ pplayer->grow(true);
pplayer->got_power = pplayer->FIRE_POWER;
}
else if (kind == UPGRADE_ICEFLOWER)
{
play_sound(sounds[SND_COFFEE], SOUND_CENTER_SPEAKER);
- pplayer->grow();
+ pplayer->grow(true);
pplayer->got_power = pplayer->ICE_POWER;
}
else if (kind == UPGRADE_FIREFLOWER)
{
play_sound(sounds[SND_COFFEE], SOUND_CENTER_SPEAKER);
- pplayer->grow();
+ pplayer->grow(true);
pplayer->got_power = pplayer->FIRE_POWER;
}
else if (kind == UPGRADE_HERRING)
void draw_part(float sx, float sy, float x, float y, float w, float h);
int get_current_frame() const;
+ float get_fps() { return fps; } ;
+ int get_frames() { return surfaces.size(); } ;
+
void draw(const Vector& pos, int special_drawing = SD_NONE)
{ draw(pos.x, pos.y, special_drawing); }
// fall through
case PlayerStatus::GROWUP_BONUS:
- tux->grow();
+ tux->grow(false);
break;
}
}