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");
(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))
#include <config.h>
#include <stdexcept>
+#include <math.h>
#include "scripted_object.hpp"
#include "video/drawing_context.hpp"
}
HitResponse
-ScriptedObject::collision(GameObject& other, const CollisionHit& )
+ScriptedObject::collision(GameObject& other, const CollisionHit& hit)
{
if(!physic_enabled)
return FORCE_MOVE;
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");