-#if CHOOSEFLAPSTYLE
- // temporary to help players choosing a flapping
- if(flapping_mode == RICARDO_FLAP) {
- // Flapping, Ricardo's version
- // similar to SM3 Fox
- if(controller->pressed(Controller::JUMP) && can_flap && flaps_nb < 3) {
- physic.set_velocity_y(350);
- physic.set_velocity_x(physic.get_velocity_x() * 35);
- flaps_nb++;
- }
- } else if(flapping_mode == MAREK_FLAP) {
-#endif
- // Flapping, Marek and Ondra's version
- if (controller->hold(Controller::JUMP) && can_flap)
- {
- if (flapping_timer.check())
- {
- can_flap = false;
- //flapping = false;
- falling_from_flap = true;
- }
- 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);
- }
- else if (cv == 0) {
- if (controller->hold(Controller::LEFT)) {
- cv = -TUX_FLAPPING_LEAST_X;
- }
- else if (controller->hold(Controller::RIGHT)) {
- cv = TUX_FLAPPING_LEAST_X;
- }
- }
- physic.set_velocity_x(cv);
- 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)
- {
- if (!flapping_timer.started())
- {
- flapping_timer.start(TUX_FLAPPING_TIME);
- }
- if (flapping_timer.check())
- {
- can_flap = false;
- falling_from_flap = true;
- }
- jumping = true;
- flapping = true;
- if (flapping && flapping_timer.get_timegone() <= TUX_FLAPPING_TIME
- && physic.get_velocity_y() < 0)
- {
- float gravity = Sector::current()->gravity;
- (void)gravity;
- float xr = (fabsf(physic.get_velocity_x()) / MAX_RUN_XM);
-
- // XXX: magic numbers. should be a percent of gravity
- // gravity is (by default) -0.1f
- physic.set_acceleration_y(12 + 1*xr);
-
-#if 0
- // To slow down x-vel when flapping (not working)
- if (fabsf(physic.get_velocity_x()) > MAX_WALK_XM)
- {
- if (physic.get_velocity_x() < 0)
- physic.set_acceleration_x(1.0f);
- else if (physic.get_velocity_x() > 0)
- physic.set_acceleration_x(-1.0f);
- }
-#endif
- }
- } else {
- physic.set_acceleration_y(0);
- }
- }
-#endif