flapping = false;
falling_from_flap = false;
if (flapping_timer.started()) {
- flapping_timer.start(0);
+ flapping_timer.stop();
}
physic.set_acceleration_y(0); //for flapping
// Press jump key
if(controller->pressed(Controller::JUMP) && can_jump && on_ground()) {
- if(duck) { // only jump a little bit when in duck mode {
+ if (duck) // only jump a little bit when in duck mode
physic.set_velocity_y(300);
- } else {
- // jump higher if we are running
- if (fabs(physic.get_velocity_x()) > MAX_WALK_XM)
- physic.set_velocity_y(580);
- else
- physic.set_velocity_y(520);
- }
+ else if (fabs(physic.get_velocity_x()) > MAX_WALK_XM) // jump higher if we are running
+ physic.set_velocity_y(580);
+ else
+ physic.set_velocity_y(520);
//bbox.move(Vector(0, -1));
jumping = true;
physic.set_velocity_y(0);
}
}
-
- // temporary to help player's choosing a flapping
+#if CHOOSEFLAPSTYLE
+ // temporary to help players choosing a flapping
if(flapping_mode == RICARDO_FLAP) {
// Flapping, Ricardo's version
// similar to SM3 Fox
flaps_nb++;
}
} else if(flapping_mode == MAREK_FLAP) {
- // Flapping, Marek's version
+#endif
+ // Flapping, Marek and Ondra's version
if (controller->hold(Controller::JUMP) && can_flap)
{
- if (!flapping_timer.started())
- {
- flapping_timer.start(TUX_FLAPPING_TIME);
- flapping_velocity = physic.get_velocity_x();
- }
if (flapping_timer.check())
{
can_flap = false;
+ //flapping = false;
falling_from_flap = true;
}
- jumping = true;
- flapping = true;
- if (!flapping_timer.check()) {
+ else if (!flapping_timer.started())
+ {
+ flapping_timer.start(TUX_FLAPPING_TIME);
+ flapping_velocity = physic.get_velocity_x();
+ }
+ else
+ {
+ jumping = true;
+ flapping = true;
float cv = flapping_velocity * sqrt(
TUX_FLAPPING_TIME - flapping_timer.get_timegone()
/ TUX_FLAPPING_TIME);
-
+
//Handle change of direction while flapping
if (((dir == LEFT) && (cv > 0)) || (dir == RIGHT) && (cv < 0)) {
cv *= (-1);
}
physic.set_velocity_x(cv);
- physic.set_velocity_y(
- flapping_timer.get_timegone()/.850);
+ physic.set_velocity_y(flapping_timer.get_timegone()
+ * TUX_FLAPPING_STRENGTH);
+ //std::cout << "Timegone: " << flapping_timer.get_timegone() << ", Y velocity: " << physic.get_velocity_y() << "\n";
}
}
+#if CHOOSEFLAPSTYLE
} else if(flapping_mode == RYAN_FLAP) {
// Flapping, Ryan's version
if (controller->hold(Controller::JUMP) && can_flap)
physic.set_acceleration_y(0);
}
}
+#endif
/* In case the player has pressed Down while in a certain range of air,
enable butt jump action */
static const float TUX_INVINCIBLE_TIME = 10.0;
static const float TUX_INVINCIBLE_TIME_WARNING = 2.0;
static const float TUX_FLAPPING_TIME = 1; /* How long Tux can flap his wings to gain additional jump height */
+static const float TUX_FLAPPING_STRENGTH = 150; /* How much velocity Tux gains when flapping */
static const float GROWING_TIME = 1.0;
static const int GROWING_FRAMES = 7;
int flaps_nb;
// temporary to help player's choosing a flapping
+ // TODO: remove this after agreeing on flapstyle!
enum { MAREK_FLAP, RICARDO_FLAP, RYAN_FLAP, NO_FLAP };
int flapping_mode;