From c8e6ab3876f5e9ed2def31eac35c1e00de509233 Mon Sep 17 00:00:00 2001 From: Matthias Braun Date: Sun, 22 Jan 2006 18:50:02 +0000 Subject: [PATCH] scripted objects correctly slide now SVN-Revision: 3025 --- data/images/engine/editor/scriptedobject.xcf | Bin 0 -> 4359 bytes data/levels/test/default.nut | 2 ++ data/levels/world1/default.nut | 4 +++- data/levels/world2/dfk-level2.stl | 2 +- data/levels/world2/level6.stl | 2 +- src/object/scripted_object.cpp | 21 ++++++++++++++++++--- 6 files changed, 25 insertions(+), 6 deletions(-) create mode 100644 data/images/engine/editor/scriptedobject.xcf diff --git a/data/images/engine/editor/scriptedobject.xcf b/data/images/engine/editor/scriptedobject.xcf new file mode 100644 index 0000000000000000000000000000000000000000..6e5bf84d688fd3437e72a5f19078dab4a97ee3d5 GIT binary patch literal 4359 zcmc&%dr(u^89(QS@D4En-fI^FH;s3gP?97Gwt@w zeD{3c@AsYWob#P??>V=kYWoiMz49&Wma1(A1ceoZ>hnM_hKCF!{Iw4eq5>rzBm^WC zWIjk1h@=8Ssmp7&Z#PuegNpT8)-3FHv*?l>tr5UeYwkvtO>zrtj75C@rt5u3)qE!GMwJyI%$hn0jY* zRXtl(U0!LZqwQe^b%y$x0Rpu9MJRyGZA!Bt6ii_GeveS(d4yu=nn96<25Q7YO$9QC zqTi^ht~b-@MT~gd|}}U!gNt*>=ouwt8)@4Jji5VBQ9`%&15>A zn^RyO#iQI9PuMjX8AhXO`Eq&ovb>zU8HO3eL)hrZU$J6&!Lqzuoq2S0jJ6Q))UOvV zFUZf!%`T8@A1ND{uT{--Vav_WFUZ%MMszuPofi5Qy5?SA#w>HDm`1W`oXlrGDhi;~&p0!bQF{*1NZDjLp5jd#&B!oSLG88fS{I)ph^DA8fXZ zH+$AP7zg*1#~pb^MON#vM*|0ca_82KbwPp~w=foH@&3@@qx*OJdN({rIL?e1A3ylw z_RZ`24zxCJg;1m87E62YoqI-;Ky-DqHWvqo_ix{Q@Mv)82_NcuXM0Nt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u2C`8PN<3ky-FGR#(*j(|L{^|t3 zEz)^piCn<;s1WNF?j>1BbHh{tk z0=V>uKnR%h47ICBD4Gw)e>{moGPq`lNC=7}9D?&ogcNX3pppnWl>{KE$UzTEfD8Bq N{Wl8jf;OBb #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"); -- 2.11.0