From: Matthias Braun Date: Sun, 22 Jan 2006 18:50:02 +0000 (+0000) Subject: scripted objects correctly slide now X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=c8e6ab3876f5e9ed2def31eac35c1e00de509233;p=supertux.git scripted objects correctly slide now SVN-Revision: 3025 --- diff --git a/data/images/engine/editor/scriptedobject.xcf b/data/images/engine/editor/scriptedobject.xcf new file mode 100644 index 000000000..6e5bf84d6 Binary files /dev/null and b/data/images/engine/editor/scriptedobject.xcf differ diff --git a/data/levels/test/default.nut b/data/levels/test/default.nut index 0358733ff..8555cbb0e 100644 --- a/data/levels/test/default.nut +++ b/data/levels/test/default.nut @@ -16,6 +16,8 @@ function intro() wait(5); Text.fade_out(2); wait(4); + + wait(20); Level.finish(); } diff --git a/data/levels/world1/default.nut b/data/levels/world1/default.nut index 335649ceb..3ac999106 100644 --- a/data/levels/world1/default.nut +++ b/data/levels/world1/default.nut @@ -37,7 +37,9 @@ function intro() wait(1) NOLOK.set_velocity(-120, 700); - wait(2); + wait(1.2); + NOLOK.set_velocity(0, 0); + wait(1); // nolok casts his spell... NOLOK.set_action("throw"); diff --git a/data/levels/world2/dfk-level2.stl b/data/levels/world2/dfk-level2.stl index 4c5337c49..f72124074 100644 --- a/data/levels/world2/dfk-level2.stl +++ b/data/levels/world2/dfk-level2.stl @@ -756,7 +756,7 @@ ) (background - (image "images/background/images/background/arctis_dark.jpg") + (image "images/background/arctis_dark.jpg") (speed 1.000000) ) (spawnpoint (name "main") (x 448) (y 2976)) diff --git a/data/levels/world2/level6.stl b/data/levels/world2/level6.stl index 4c9f4dff1..b3b6b71a0 100644 --- a/data/levels/world2/level6.stl +++ b/data/levels/world2/level6.stl @@ -942,7 +942,7 @@ (spawnpoint (name "main") (x 64) (y 9536)) (background - (image "images/background/images/background/forest1.jpg") + (image "images/background/forest1.jpg") (speed 1.000000) ) (poisonivy (x 1349) (y 8844)) diff --git a/src/object/scripted_object.cpp b/src/object/scripted_object.cpp index b9378fde5..53ef31715 100644 --- a/src/object/scripted_object.cpp +++ b/src/object/scripted_object.cpp @@ -1,6 +1,7 @@ #include #include +#include #include "scripted_object.hpp" #include "video/drawing_context.hpp" @@ -140,7 +141,7 @@ ScriptedObject::draw(DrawingContext& context) } HitResponse -ScriptedObject::collision(GameObject& other, const CollisionHit& ) +ScriptedObject::collision(GameObject& other, const CollisionHit& hit) { if(!physic_enabled) return FORCE_MOVE; @@ -148,8 +149,22 @@ ScriptedObject::collision(GameObject& other, const CollisionHit& ) if(!(other.get_flags() & FLAG_SOLID)) return FORCE_MOVE; - physic.set_velocity(0, 0); - return CONTINUE; + if(other.get_flags() & FLAG_SOLID) { + if(hit.normal.y < 0) { // landed on floor + if(physic.get_velocity_y() < 0) + physic.set_velocity_y(0); + } else if(hit.normal.y > 0) { // bumped against roof + physic.set_velocity_y(.1); + } + + if(fabsf(hit.normal.x) > .9) { // hit on side? + physic.set_velocity_x(0); + } + + return CONTINUE; + } + + return FORCE_MOVE; } IMPLEMENT_FACTORY(ScriptedObject, "scriptedobject");