frame_main = 0;
frame_ = 0;
- lives = 3;
- score = 0;
- distros = 0;
-
+
player_input_init(&input);
keymap.jump = SDLK_UP;
/* Move tux: */
previous_base = base;
- duck = false;
physic.apply(frame_ratio, base.x, base.y);
if(dying == DYING_NOT) {
play_current_music();
}
- /* End of level? */
- if (base.x >= World::current()->get_level()->endpos
- && World::current()->get_level()->endpos != 0)
- {
- player_status.next_level = 1;
- }
-
- /* Duck! */
- if (input.down == DOWN && size == BIG && !duck)
- {
- duck = true;
- base.height = 32;
- base.y += 32;
- // changing base size confuses collision otherwise
- old_base = previous_base = base;
- }
- else if(input.down == UP && size == BIG && duck)
- {
- duck = false;
- base.y -= 32;
- base.height = 64;
- old_base = previous_base = base;
- }
-
// check some timers
skidding_timer.check();
invincible_timer.check();
ax = WALK_ACCELERATION_X * -1.5;
}
}
-
+
+ // if we're on ice slow down acceleration or deceleration
+ if (isice(base.x, base.y + base.height))
+ {
+ /* the acceleration/deceleration rate on ice is inversely proportional to
+ * the current velocity.
+ */
+
+ // increasing 1 will increase acceleration/deceleration rate
+ // decreasing 1 will decrease acceleration/deceleration rate
+ // must stay above zero, though
+ if (ax != 0) ax *= 1 / fabs(vx);
+ }
+
physic.set_velocity(vx, vy);
physic.set_acceleration(ax, ay);
}
}
/* Enough distros for a One-up? */
- if (distros >= DISTROS_LIFEUP)
+ if (player_status.distros >= DISTROS_LIFEUP)
{
- distros = distros - DISTROS_LIFEUP;
- if(lives < MAX_LIVES)
- lives++;
+ player_status.distros = player_status.distros - DISTROS_LIFEUP;
+ if(player_status.lives < MAX_LIVES)
+ ++player_status.lives;
/*We want to hear the sound even, if MAX_LIVES is reached*/
play_sound(sounds[SND_LIFEUP], SOUND_CENTER_SPEAKER);
}
}
}
- if(dying)
- gold_text->drawf("Penguins can fly !:",0,0,A_HMIDDLE,A_VMIDDLE,1);
-
if (debug_mode)
fillrect(base.x - scroll_x, base.y, 32, 32, 75,75,75, 150);
}
{
case CO_BADGUY:
pbad_c = (BadGuy*) p_c_object;
- /* Hurt the player if he just touched it: */
+ /* Hurt player if he touches a badguy */
if (!pbad_c->dying && !dying &&
!safe_timer.started() &&
pbad_c->mode != HELD)
pbad_c->mode = HELD;
pbad_c->base.y-=8;
}
+ else if (pbad_c->mode == FLAT)
+ {
+ // Don't get hurt if we're kicking a flat badguy!
+ }
else if (pbad_c->mode == KICK)
{
- if (base.y < pbad_c->base.y - 16)
+ /* Hurt if you get hit by kicked laptop: */
+ if (!invincible_timer.started())
{
- /* Step on (stop being kicked) */
-
- pbad_c->mode = FLAT;
- play_sound(sounds[SND_STOMP], SOUND_CENTER_SPEAKER);
+ kill(SHRINK);
}
else
{
- /* Hurt if you get hit by kicked laptop: */
- if (!invincible_timer.started())
- {
- kill(SHRINK);
- }
- else
- {
- pbad_c->dying = DYING_FALLING;
- play_sound(sounds[SND_FALL], SOUND_CENTER_SPEAKER);
- World::current()->add_score(pbad_c->base.x - scroll_x,
- pbad_c->base.y,
- 25 * player_status.score_multiplier);
- }
+ pbad_c->dying = DYING_FALLING;
+ play_sound(sounds[SND_FALL], SOUND_CENTER_SPEAKER);
+ World::current()->add_score(pbad_c->base.x - scroll_x,
+ pbad_c->base.y,
+ 25 * player_status.score_multiplier);
}
}
else
void
Player::is_dying()
{
- /* He died :^( */
-
- --lives;
remove_powerups();
dying = DYING_NOT;
}