From: Matthias Braun Date: Sat, 31 Dec 2005 15:59:22 +0000 (+0000) Subject: some more work on portable objects X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=fbf5cd9ecbfa34368697837587873d82a098494f;p=supertux.git some more work on portable objects SVN-Revision: 2970 --- diff --git a/data/levels/test/simple.stl b/data/levels/test/simple.stl index 4a8a4febb..a4adb6f13 100644 --- a/data/levels/test/simple.stl +++ b/data/levels/test/simple.stl @@ -6,15 +6,13 @@ (time 999) (sector (name "main") - (width 30) - (height 20) (gravity 10.000000) (background (image "arctis.jpg") (speed 0.5)) - (spawnpoint (name "main") (x 150) (y 200)) + (spawnpoint (name "main") (x 150) (y 100)) (rock (x 50) (y 50)) - (rock (x 50) (y 100)) - (rock (x 50) (y 150)) + ;;(rock (x 50) (y 100)) + ;;(rock (x 50) (y 150)) (tilemap (layer "background") (solid #f) diff --git a/src/object/player.cpp b/src/object/player.cpp index 566bcd8b1..2c4f58017 100644 --- a/src/object/player.cpp +++ b/src/object/player.cpp @@ -154,19 +154,19 @@ Player::update(float elapsed_time) } if(!controller->hold(Controller::ACTION) && grabbed_object) { - grabbed_object = 0; // move the grabbed object a bit away from tux Vector pos = get_pos() + - Vector(dir == LEFT ? -bbox.get_width() : bbox.get_width(), + Vector(dir == LEFT ? -bbox.get_width()-1 : bbox.get_width()+1, bbox.get_height()*0.66666 - 32); - MovingObject* object = dynamic_cast (grabbed_object); - if(object) { - object->set_pos(pos); + MovingObject* moving_object = dynamic_cast (grabbed_object); + if(moving_object) { + moving_object->set_pos(pos); } else { #ifdef DEBUG std::cout << "Non MovingObjetc grabbed?!?\n"; #endif } + grabbed_object = 0; } if(!dying && !deactivated) diff --git a/src/object/portable.hpp b/src/object/portable.hpp index 5b74e1de8..ae7199b64 100644 --- a/src/object/portable.hpp +++ b/src/object/portable.hpp @@ -38,12 +38,6 @@ public: * called each frame when the object has been grabbed. */ virtual void grab(MovingObject& object, const Vector& pos) = 0; - - /** called when object isn't grabbed anymore */ - virtual void ungrab(MovingObject& object) - { - (void) object; - } }; #endif diff --git a/src/object/rock.cpp b/src/object/rock.cpp index e6862f315..df1371c89 100644 --- a/src/object/rock.cpp +++ b/src/object/rock.cpp @@ -56,7 +56,6 @@ Rock::write(lisp::Writer& writer) void Rock::draw(DrawingContext& context) { - sprite->draw(context, get_pos(), LAYER_OBJECTS); } @@ -65,7 +64,7 @@ Rock::update(float elapsed_time) { if(!grabbed) { flags |= FLAG_SOLID; - set_group(COLGROUP_STATIC); + set_group(COLGROUP_MOVING); movement = physic.get_movement(elapsed_time); } else { physic.set_velocity(0, 0); @@ -79,12 +78,13 @@ Rock::update(float elapsed_time) HitResponse Rock::collision(GameObject& object, const CollisionHit& ) { - if(grabbed) + if(grabbed) { return FORCE_MOVE; + } if(object.get_flags() & FLAG_SOLID) { - physic.set_velocity(0, 0); - return CONTINUE; + physic.set_velocity(0, 0); + return CONTINUE; } return FORCE_MOVE; diff --git a/src/object/rock.hpp b/src/object/rock.hpp index 28be0e6c9..9e48d1b24 100644 --- a/src/object/rock.hpp +++ b/src/object/rock.hpp @@ -17,7 +17,6 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA // 02111-1307, USA. - #ifndef __ROCK_H__ #define __ROCK_H__