scripted objects correctly slide now
authorMatthias Braun <matze@braunis.de>
Sun, 22 Jan 2006 18:50:02 +0000 (18:50 +0000)
committerMatthias Braun <matze@braunis.de>
Sun, 22 Jan 2006 18:50:02 +0000 (18:50 +0000)
SVN-Revision: 3025

data/images/engine/editor/scriptedobject.xcf [new file with mode: 0644]
data/levels/test/default.nut
data/levels/world1/default.nut
data/levels/world2/dfk-level2.stl
data/levels/world2/level6.stl
src/object/scripted_object.cpp

diff --git a/data/images/engine/editor/scriptedobject.xcf b/data/images/engine/editor/scriptedobject.xcf
new file mode 100644 (file)
index 0000000..6e5bf84
Binary files /dev/null and b/data/images/engine/editor/scriptedobject.xcf differ
index 0358733..8555cbb 100644 (file)
@@ -16,6 +16,8 @@ function intro()
   wait(5);
   Text.fade_out(2);     
   wait(4);
+
+  wait(20);
   Level.finish();
 }
 
index 335649c..3ac9991 100644 (file)
@@ -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");
index 4c5337c..f721240 100644 (file)
     )
 
        (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))
index 4c9f4df..b3b6b71 100644 (file)
 
        (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))
index b9378fd..53ef317 100644 (file)
@@ -1,6 +1,7 @@
 #include <config.h>
 
 #include <stdexcept>
+#include <math.h>
 
 #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");