(name "diving-right")
(x-offset 2)
(y-offset 4)
- (mirror-action "left")))
+ (mirror-action "diving-left")
+ )
+)
(start_pos_x 100)
(start_pos_y 100)
(background "")
- (music "music/music/chipdisko.ogg")
+ (music "music/chipdisko.ogg")
(bkgd_red_top 60)
(bkgd_green_top 70)
(bkgd_blue_top 110)
kill_fall();
return ABORT_MOVE;
}
+
// hit from above?
if(player.get_movement().y - get_movement().y > 0 && player.get_bbox().p2.y <
(get_bbox().p1.y + get_bbox().p2.y) / 2) {
// if it's not possible to squish us, then this will hurt
- if(!collision_squished(player))
- player.kill(Player::SHRINK);
-
- return FORCE_MOVE;
+ if(collision_squished(player))
+ return CONTINUE;
}
+
player.kill(Player::SHRINK);
return FORCE_MOVE;
}
/** Writes out the badguy into the included lisp::Writer. Useful e.g. when
* converting an old-format level to the new format.
*/
- virtual void save(lisp::Writer& );
+ virtual void save(lisp::Writer& writer);
Vector get_start_position() const
{
void
Player::update(float elapsed_time)
{
+ // do we need to enable gravity again?
+ if(on_ground_flag) {
+ Rect lower = bbox;
+ lower.move(Vector(0, 4.0));
+ if(Sector::current()->is_free_space(lower)) {
+ physic.enable_gravity(true);
+ on_ground_flag = false;
+ }
+ }
+
if(dying && dying_timer.check()) {
dead = true;
return;
}
- // fixes the "affected even while blinking" bug
- if (safe_timer.started() && this->get_group() != COLGROUP_MOVING_ONLY_STATIC) {
- this->set_group(COLGROUP_MOVING_ONLY_STATIC);
- }
- else if (!safe_timer.started() && this->get_group() == COLGROUP_MOVING_ONLY_STATIC) {
- this->set_group(COLGROUP_MOVING);
- }
-
if(!controller->hold(Controller::ACTION) && grabbed_object) {
// move the grabbed object a bit away from tux
Vector pos = get_pos() +
handle_input();
movement = physic.get_movement(elapsed_time);
- on_ground_flag = false;
#if 0
// special exception for cases where we're stuck under tiles after
// extend/shrink tux collision rectangle so that we fall through/walk over 1
// tile holes
if(fabsf(vx) > MAX_WALK_XM) {
- bbox.set_width(33);
+ bbox.set_width(34);
} else {
bbox.set_width(31.8);
}
floor_normal.y = (floor_normal.y * 0.9) + (hit.normal.y * 0.1);
}
+ // disable gravity
+ physic.enable_gravity(false);
} else if(hit.normal.y > 0) { // bumped against the roof
physic.set_velocity_y(.1);
}
}
BadGuy* badguy = dynamic_cast<BadGuy*> (&other);
- if(badguy != NULL)
+ if(badguy != NULL) {
+ if(safe_timer.started())
+ return FORCE_MOVE;
+
return CONTINUE;
+ }
return FORCE_MOVE;
}
bbox.set_size(31.8, 63.8);
else
bbox.set_size(31.8, 31.8);
- on_ground_flag = false;
duck = false;
last_ground_y = vector.y;
#include "physic.hpp"
Physic::Physic()
- : ax(0), ay(0), vx(0), vy(0), gravity_enabled(true)
+ : ax(0), ay(0), vx(0), vy(0), gravity_enabled_flag(true)
{
}
Physic::reset()
{
ax = ay = vx = vy = 0;
- gravity_enabled = true;
+ gravity_enabled_flag = true;
}
void
void
Physic::enable_gravity(bool enable_gravity)
{
- gravity_enabled = enable_gravity;
+ gravity_enabled_flag = enable_gravity;
+}
+
+bool
+Physic::gravity_enabled() const
+{
+ return gravity_enabled_flag;
}
Vector
Physic::get_movement(float elapsed_time)
{
- float grav = gravity_enabled ? 1000 : 0;
+ float grav = gravity_enabled_flag ? 1000 : 0;
Vector result(
vx * elapsed_time + ax * elapsed_time * elapsed_time,
/// Enables or disables handling of gravity.
void enable_gravity(bool gravity_enabled);
+ bool gravity_enabled() const;
Vector get_movement(float elapsed_time);
/// horizontal and vertical velocity
float vx, vy;
/// should we respect gravity in out calculations?
- bool gravity_enabled;
+ bool gravity_enabled_flag;
};
#endif