From 6f92944e2238c19283a0776e63f469b3345bccd2 Mon Sep 17 00:00:00 2001 From: Wolfgang Becker Date: Sat, 15 Jul 2006 23:54:29 +0000 Subject: [PATCH] Let's Rock SVN-Revision: 4026 --- data/levels/test/rock.stl | 195 ++++++++++++++++++++++------------------ data/levels/test/trampoline.stl | 8 ++ src/object/rock.cpp | 61 ++++++++----- src/object/rock.hpp | 3 +- src/object/trampoline.cpp | 8 ++ 5 files changed, 163 insertions(+), 112 deletions(-) diff --git a/data/levels/test/rock.stl b/data/levels/test/rock.stl index d9d9edc27..c94cc241c 100644 --- a/data/levels/test/rock.stl +++ b/data/levels/test/rock.stl @@ -1,107 +1,126 @@ -;; Generated by Flexlay Editor (supertux-level (version 2) - (name "Bonus Block Test") + (name (_ "Bonus Block Test")) (author "SuperTux Team") - (time 999) (sector - (name "main") - (gravity 10.000000) - (background (image "images/background/arctis.jpg") - (speed 0.5)) - (spawnpoint (name "main") (x 150) (y 100)) - (rock (x 50) (y 50)) - (rock (x 50) (y 100)) - ;(rock (x 50) (y 150)) + (name "main") + (background + (speed 0.5) + (image "images/background/arctis.jpg") + ) (tilemap (z-pos -100) (solid #f) - (speed 1.000000) - (width 30) + (speed 1) + (width 30) (height 20) - (tiles - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 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 0 0 0 0 0) + ) (tilemap (z-pos 0) (solid #t) - (speed 1.000000) - (width 30) + (speed 1) + (width 30) (height 20) - (tiles - 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 - 61 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 61 - 61 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 61 - 61 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 61 - 61 0 0 0 1048 1052 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 61 - 61 0 0 0 1009 1048 1052 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 48 48 48 61 - 61 0 0 0 1009 1009 1048 1052 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 61 - 61 0 0 0 0 1009 1009 1048 1052 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 61 - 61 0 0 0 0 0 1009 1009 1048 0 0 48 0 48 0 48 0 48 0 0 0 0 0 0 0 0 0 0 0 61 - 61 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 48 48 48 48 48 61 - 61 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 61 - 61 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 61 - 61 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 61 - 61 0 0 0 0 0 1063 0 1064 0 1065 0 1066 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 61 - 61 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 48 48 0 0 0 0 0 0 0 61 - 61 48 0 0 0 0 0 0 0 0 0 0 48 48 0 0 0 0 0 0 48 48 0 0 0 0 0 0 0 61 - 61 48 48 48 0 1311 0 0 0 0 0 0 48 48 0 0 0 0 0 0 48 48 0 0 0 0 0 0 0 61 - 61 0 0 0 0 0 0 0 0 0 0 0 48 48 0 0 0 0 0 0 48 48 0 0 0 0 0 0 48 61 - 61 0 0 0 0 0 0 0 0 0 0 0 48 48 0 0 0 0 0 0 48 48 0 0 0 0 0 0 0 61 - 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 - )) + (tiles 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 61 61 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 61 61 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 61 61 0 0 0 1048 1052 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 48 0 0 0 0 0 0 0 61 61 0 0 0 1009 1048 1052 0 0 0 0 0 0 0 0 0 0 0 0 0 0 48 48 48 0 0 48 48 48 61 61 0 0 0 1009 1009 1048 1052 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 61 61 0 0 0 0 1009 1009 1048 1052 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 61 61 0 0 0 0 0 1009 1009 1048 0 0 48 0 48 0 48 0 48 0 0 0 0 0 0 48 0 0 0 0 61 61 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 48 48 48 48 48 61 61 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 61 61 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 61 61 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 61 61 0 0 0 0 0 1 0 1 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 61 61 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 48 48 0 0 0 0 0 0 0 61 61 48 0 0 0 0 0 0 0 0 0 0 48 48 0 0 0 0 0 0 48 48 0 0 0 0 0 0 0 61 61 48 48 48 0 1 0 0 0 0 0 0 48 48 0 0 0 1 1 1 48 48 0 0 0 0 0 0 0 61 61 0 0 0 0 0 0 0 0 0 0 0 48 48 0 0 0 0 0 0 48 48 0 0 0 0 0 0 48 61 61 0 0 0 0 0 0 0 0 0 0 0 48 48 0 0 0 0 0 0 48 48 0 0 0 0 0 0 0 61 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27) + ) (tilemap (z-pos 100) (solid #f) - (speed 1.000000) - (width 30) + (speed 1) + (width 30) (height 20) - (tiles - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0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bomb + (direction "auto") + (x 736) + (y 416) + (sprite "") + ) + (snowball + (direction "auto") + (x 896) + (y 128) + ) + (spawnpoint + (name "main") + (x 150) + (y 100) + ) + (rock + (x 50) + (y 50) + ) + (rock + (x 50) + (y 100) + ) + (rock + (x 736) + (y 544) + ) + (rock + (x 736) + (y 576) + ) + (rock + (x 768) + (y 576) + ) + (rock + (x 768) + (y 544) + ) + (rock + (x 736) + (y 512) + ) + (rock + (x 768) + (y 512) + ) + (rock + (x 768) + (y 480) + ) + (rock + (x 736) + (y 480) + ) + (rock + (x 800) + (y 256) + ) + (rock + (x 768) + (y 224) + ) + (rock + (x 800) + (y 224) + ) + (rock + (x 768) + (y 192) + ) + (rock + (x 800) + (y 192) + ) + (rock + (x 768) + (y 160) + ) + (rock + (x 800) + (y 160) + ) + ) +) diff --git a/data/levels/test/trampoline.stl b/data/levels/test/trampoline.stl index 84ae104ff..9d175f575 100644 --- a/data/levels/test/trampoline.stl +++ b/data/levels/test/trampoline.stl @@ -63,5 +63,13 @@ (y 1056) (portable #f) ) + (rock + (x 32) + (y 1056) + ) + (rock + (x 32) + (y 1024) + ) ) ) diff --git a/src/object/rock.cpp b/src/object/rock.cpp index 1ffa23167..467377ce5 100644 --- a/src/object/rock.cpp +++ b/src/object/rock.cpp @@ -26,9 +26,9 @@ #include "object_factory.hpp" Rock::Rock(const lisp::Lisp& reader) - : MovingSprite(reader, "images/objects/rock/rock.sprite", LAYER_OBJECTS+1, COLGROUP_STATIC) + : MovingSprite(reader, "images/objects/rock/rock.sprite") { - grabbed = false; + on_ground = false; flags |= FLAG_SOLID | FLAG_PORTABLE; } @@ -46,45 +46,60 @@ Rock::write(lisp::Writer& writer) void Rock::update(float elapsed_time) { - if(!grabbed) { - flags |= FLAG_SOLID; - set_group(COLGROUP_STATIC); + if( !on_ground ) { movement = physic.get_movement(elapsed_time); - } else { - physic.set_velocity(0, 0); - flags &= ~FLAG_SOLID; - set_group(COLGROUP_DISABLED); } - - grabbed = false; - /* - printf("%p - V %3.1f %3.1f - P %3.1f %3.1f\n", this, - physic.get_velocity().x, physic.get_velocity().y, - get_pos().x, get_pos().y); - */ } void -Rock::collision_solid(const CollisionHit& ) +Rock::collision_solid(const CollisionHit& hit) { physic.set_velocity(0, 0); + if( hit.bottom ){ + on_ground = true; + } } HitResponse -Rock::collision(GameObject& , const CollisionHit& ) +Rock::collision(GameObject& other, const CollisionHit& hit) { - if(grabbed) { - return PASSTHROUGH; + if( !on_ground ){ + return FORCE_MOVE; } - - return SOLID; + + //Fake being solid for moving_object. + MovingObject* moving_object = dynamic_cast (&other); + if( moving_object ){ + if( hit.top ){ + float inside = moving_object->get_bbox().get_bottom() - get_bbox().get_top(); + if( inside > 0 ){ + Vector pos = moving_object->get_pos(); + pos.y -= inside; + moving_object->set_pos( pos ); + } + } + CollisionHit hit_other = hit; + std::swap(hit_other.left, hit_other.right); + std::swap(hit_other.top, hit_other.bottom); + moving_object->collision_solid( hit_other ); + } + return FORCE_MOVE; } void Rock::grab(MovingObject& , const Vector& pos, Direction) { movement = pos - get_pos(); - grabbed = true; + set_group( COLGROUP_DISABLED ); + on_ground = true; + +} + +void +Rock::ungrab(MovingObject& , Direction ){ + set_group( COLGROUP_MOVING ); + on_ground = false; + physic.set_velocity(0, 0); } IMPLEMENT_FACTORY(Rock, "rock"); diff --git a/src/object/rock.hpp b/src/object/rock.hpp index 207095e78..7303fe138 100644 --- a/src/object/rock.hpp +++ b/src/object/rock.hpp @@ -40,9 +40,10 @@ public: void write(lisp::Writer& writer); void grab(MovingObject& object, const Vector& pos, Direction dir); + void ungrab(MovingObject& object, Direction dir); private: - bool grabbed; + bool on_ground; Physic physic; }; diff --git a/src/object/trampoline.cpp b/src/object/trampoline.cpp index 7df1e312d..91702d482 100644 --- a/src/object/trampoline.cpp +++ b/src/object/trampoline.cpp @@ -92,6 +92,14 @@ Trampoline::collision(GameObject& other, const CollisionHit& hit ) //Fake being solid for moving_object. MovingObject* moving_object = dynamic_cast (&other); if( moving_object ){ + if( hit.top ){ + float inside = moving_object->get_bbox().get_bottom() - get_bbox().get_top(); + if( inside > 0 ){ + Vector pos = moving_object->get_pos(); + pos.y -= inside; + moving_object->set_pos( pos ); + } + } CollisionHit hit_other = hit; std::swap(hit_other.left, hit_other.right); std::swap(hit_other.top, hit_other.bottom); -- 2.11.0