You can tweak its speed in the GROWING_TIME define on player.h (in ms).
It's strange, but I have to pass 'false' for the use_alpha parameter in Surface. Else, it wouldn't use alpha... Something is definitively wrong.
SVN-Revision: 1412
// others stuff:
#define AUTOSCROLL_DEAD_INTERVAL 300
+// growing animation
+Surface* growingtux_left[GROWING_FRAMES];
+Surface* growingtux_right[GROWING_FRAMES];
+
Surface* tux_life;
Sprite* smalltux_gameover;
Sprite* smalltux_star;
Sprite* largetux_star;
-Sprite* growingtux_left;
-Sprite* growingtux_right;
PlayerSprite smalltux;
PlayerSprite largetux;
frame_main = 0;
frame_ = 0;
-
+
player_input_init(&input);
invincible_timer.init(true);
base.y -= 32;
if(animate)
- growing_timer.start((int)((growingtux_left->get_frames() / growingtux_left->get_fps()) * 1000));
+ growing_timer.start(GROWING_TIME);
old_base = previous_base = base;
}
if(growing_timer.check())
{
if (dir == RIGHT)
- growingtux_right->draw(context, pos, layer);
+ context.draw_surface(growingtux_right[(growing_timer.get_gone() * GROWING_FRAMES) / GROWING_TIME], pos, layer);
else
- growingtux_left->draw(context, pos, layer);
+ context.draw_surface(growingtux_left[(growing_timer.get_gone() * GROWING_FRAMES) / GROWING_TIME], pos, layer);
}
else if (duck && size != SMALL)
{
extern Sprite* smalltux_gameover;
extern Sprite* smalltux_star;
extern Sprite* largetux_star;
-extern Sprite* growingtux_left;
-extern Sprite* growingtux_right;
+
+#define GROWING_TIME 1000
+#define GROWING_FRAMES 7
+extern Surface* growingtux_left[GROWING_FRAMES];
+extern Surface* growingtux_right[GROWING_FRAMES];
struct PlayerSprite
{
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");
+ char img_name[1024];
+ for (int i = 0; i < GROWING_FRAMES; i++)
+ {
+ sprintf(img_name, "%s/images/shared/tux-grow-left-%i.png", datadir.c_str(), i+1);
+ growingtux_left[i] = new Surface(img_name, false);
+
+ sprintf(img_name, "%s/images/shared/tux-grow-right-%i.png", datadir.c_str(), i+1);
+ growingtux_right[i] = new Surface(img_name, false);
+ }
smalltux.stand_left = sprite_manager->load("smalltux-stand-left");
smalltux.stand_right = sprite_manager->load("smalltux-stand-right");
delete tux_life;
+ for (int i = 0; i < GROWING_FRAMES; i++)
+ {
+ delete growingtux_left[i];
+ delete growingtux_right[i];
+ }
+
for (i = 0; i < NUM_SOUNDS; i++)
free_chunk(sounds[i]);