// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <math.h>
-
#include "gameloop.h"
#include "globals.h"
#include "player.h"
pplayer_input->old_fire = UP;
pplayer_input->right = UP;
pplayer_input->up = UP;
+ pplayer_input->old_up = UP;
}
void
dying = DYING_NOT;
jumping = false;
+ can_jump = true;
frame_main = 0;
frame_ = 0;
skidding_timer.init(true);
safe_timer.init(true);
frame_timer.init(true);
+ kick_timer.init(true);
physic.reset();
}
skidding_timer.check();
invincible_timer.check();
safe_timer.check();
+ kick_timer.check();
}
bool
void
Player::handle_vertical_input()
{
- if(input.up == DOWN)
+ // Press jump key
+ if(input.up == DOWN && can_jump)
{
if (on_ground())
{
// jump higher if we are running
- if (physic.get_velocity_x() > MAX_WALK_XM)
+ if (fabs(physic.get_velocity_x()) > MAX_WALK_XM)
physic.set_velocity_y(5.8);
else
physic.set_velocity_y(5.2);
--base.y;
jumping = true;
+ can_jump = false;
if (size == SMALL)
play_sound(sounds[SND_JUMP], SOUND_CENTER_SPEAKER);
else
play_sound(sounds[SND_BIGJUMP], SOUND_CENTER_SPEAKER);
}
}
+ // Let go of jump key
else if(input.up == UP && jumping)
{
jumping = false;
physic.set_velocity_y(0);
}
}
+
+ if ( (issolid(base.x + base.width / 2, base.y + base.height + 64) ||
+ issolid(base.x + 1, base.y + base.height + 64) ||
+ issolid(base.x + base.width - 1, base.y + base.height + 64))
+ && jumping == false
+ && can_jump == false
+ && input.up == DOWN
+ && input.old_up == UP)
+ {
+ can_jump = true;
+ }
+
+ input.old_up = input.up;
}
void
/* Jump/jumping? */
- if ( input.up == DOWN || (input.up == UP && jumping))
+ if (on_ground() && input.up == UP)
+ can_jump = true;
+ if (input.up == DOWN || (input.up == UP && jumping))
{
handle_vertical_input();
}
duck = false;
base.y -= 32;
base.height = 64;
- old_base = previous_base = base;
+ // changing base size confuses collision otherwise
+ old_base = previous_base = base;
}
}
void
+Player::grow()
+{
+ if(size == BIG)
+ return;
+
+ size = BIG;
+ base.height = 64;
+ base.y -= 32;
+
+ old_base = previous_base = base;
+}
+
+void
Player::grabdistros()
{
/* Grab distros: */
else
sprite = &largetux;
- if (duck)
+ if (duck && size != SMALL)
{
if (dir == RIGHT)
sprite->duck_right->draw(base.x - scroll_x, base.y);
else
sprite->duck_left->draw(base.x - scroll_x, base.y);
- }
+ }
else if (skidding_timer.started())
{
if (dir == RIGHT)
else
sprite->skid_left->draw(base.x - scroll_x, base.y);
}
+ else if (kick_timer.started())
+ {
+ if (dir == RIGHT)
+ sprite->kick_right->draw(base.x - scroll_x, base.y);
+ else
+ sprite->kick_left->draw(base.x - scroll_x, base.y);
+ }
else if (physic.get_velocity_y() != 0)
{
if (dir == RIGHT)
}
// Draw blinking star overlay
- if (invincible_timer.started())
+ if (invincible_timer.started() &&
+ (invincible_timer.get_left() > TUX_INVINCIBLE_TIME_WARNING || global_frame_counter % 3))
{
if (size == SMALL || duck)
smalltux_star->draw(base.x - scroll_x, base.y);
!safe_timer.started() &&
pbad_c->mode != BadGuy::HELD)
{
- if (pbad_c->mode == BadGuy::FLAT && input.fire == DOWN)
+ if (pbad_c->mode == BadGuy::FLAT && input.fire == DOWN
+ && !holding_something)
{
holding_something = true;
pbad_c->mode = BadGuy::HELD;
}
else
{
- pbad_c->kill_me();
+ pbad_c->kill_me(25);
}
}
player_status.score_multiplier++;