From: Ondřej Hošek Date: Sun, 6 Nov 2005 18:11:18 +0000 (+0000) Subject: * Added a boolean "disable-physics" property to powerups. We can't afford losing... X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=dc6ea373b9c788755d8eb8f46db8728140cb4c1b;p=supertux.git * Added a boolean "disable-physics" property to powerups. We can't afford losing e.g. the key in w2l2 after all the flipping of the level. SVN-Revision: 2948 --- diff --git a/data/levels/world2/level2.stl b/data/levels/world2/level2.stl index 6539e064e..6f91f86c3 100644 --- a/data/levels/world2/level2.stl +++ b/data/levels/world2/level2.stl @@ -217,6 +217,7 @@ (powerup (x 8000) (y 352) (sprite "key-gold") (script "get_gold_key();") + (disable-physics #t) ) (infoblock (x 2560) (y 320) (message (_ "-Oh no! diff --git a/src/object/powerup.cpp b/src/object/powerup.cpp index 9d3ff9359..c9733c690 100644 --- a/src/object/powerup.cpp +++ b/src/object/powerup.cpp @@ -36,6 +36,8 @@ PowerUp::PowerUp(const lisp::Lisp& lisp) lisp.get("y", bbox.p1.y); lisp.get("sprite", sprite_name); lisp.get("script", script); + no_physics = false; + lisp.get("disable-physics", no_physics); bbox.set_size(32, 32); sprite = sprite_manager->create(sprite_name); physic.enable_gravity(true); @@ -89,7 +91,8 @@ PowerUp::collision(GameObject& other, const CollisionHit& hit) void PowerUp::update(float elapsed_time) { - movement = physic.get_movement(elapsed_time); + if (!no_physics) + movement = physic.get_movement(elapsed_time); } void diff --git a/src/object/powerup.hpp b/src/object/powerup.hpp index 99d522a6b..7e3446466 100644 --- a/src/object/powerup.hpp +++ b/src/object/powerup.hpp @@ -40,6 +40,7 @@ private: Sprite* sprite; Physic physic; std::string script; + bool no_physics; }; #endif