From: Matthias Braun Date: Wed, 24 Nov 2004 14:10:27 +0000 (+0000) Subject: furhter improve collision detection by reintroducing time of collision, still more... X-Git-Url: https://git.octo.it/?a=commitdiff_plain;h=e4d4375bf4b6802321d956f5f3886320b7275cf0;p=supertux.git furhter improve collision detection by reintroducing time of collision, still more issues to solve SVN-Revision: 2168 --- diff --git a/data/levels/test/bonusblock.stl b/data/levels/test/bonusblock.stl index e26bb65d6..ffa1bb294 100644 --- a/data/levels/test/bonusblock.stl +++ b/data/levels/test/bonusblock.stl @@ -6,8 +6,6 @@ (time 999) (sector (name "main") - (width 30) - (height 30) (gravity 10.000000) (background (image "arctis.jpg") (speed 0.5)) diff --git a/lib/app/globals.h b/lib/app/globals.h index f1ba02980..7c76c0de2 100644 --- a/lib/app/globals.h +++ b/lib/app/globals.h @@ -26,7 +26,7 @@ #include "SDL.h" -#include "../video/font.h" +#include "video/font.h" #include "tinygettext.h" namespace SuperTux diff --git a/lib/app/setup.cpp b/lib/app/setup.cpp index ba520c096..fb41e0ffd 100644 --- a/lib/app/setup.cpp +++ b/lib/app/setup.cpp @@ -43,14 +43,14 @@ #include -#include "../app/globals.h" -#include "../app/setup.h" -#include "../video/screen.h" -#include "../video/surface.h" -#include "../gui/menu.h" -#include "../utils/configfile.h" -#include "../audio/sound_manager.h" -#include "../app/gettext.h" +#include "globals.h" +#include "setup.h" +#include "video/screen.h" +#include "video/surface.h" +#include "gui/menu.h" +#include "utils/configfile.h" +#include "audio/sound_manager.h" +#include "gettext.h" using namespace SuperTux; diff --git a/lib/audio/musicref.cpp b/lib/audio/musicref.cpp index e7b613e07..a29db19ff 100644 --- a/lib/audio/musicref.cpp +++ b/lib/audio/musicref.cpp @@ -20,7 +20,7 @@ #include -#include "../audio/musicref.h" +#include "audio/musicref.h" using namespace SuperTux; diff --git a/lib/audio/musicref.h b/lib/audio/musicref.h index d433787d4..f50538b0f 100644 --- a/lib/audio/musicref.h +++ b/lib/audio/musicref.h @@ -20,7 +20,7 @@ #ifndef SUPERTUX_MUSICREF_H #define SUPERTUX_MUSICREF_H -#include "../audio/sound_manager.h" +#include "sound_manager.h" namespace SuperTux { diff --git a/lib/audio/sound_manager.cpp b/lib/audio/sound_manager.cpp index f721f3fd9..283fbba2c 100644 --- a/lib/audio/sound_manager.cpp +++ b/lib/audio/sound_manager.cpp @@ -22,11 +22,11 @@ #include #include -#include "../audio/sound_manager.h" -#include "../audio/musicref.h" -#include "../app/globals.h" -#include "../app/setup.h" -#include "../special/moving_object.h" +#include "audio/sound_manager.h" +#include "audio/musicref.h" +#include "app/globals.h" +#include "app/setup.h" +#include "special/moving_object.h" using namespace SuperTux; diff --git a/lib/audio/sound_manager.h b/lib/audio/sound_manager.h index b9878e400..9eece9c83 100644 --- a/lib/audio/sound_manager.h +++ b/lib/audio/sound_manager.h @@ -25,7 +25,7 @@ #include #include "SDL_mixer.h" -#include "../math/vector.h" +#include "math/vector.h" namespace SuperTux { diff --git a/lib/gui/button.cpp b/lib/gui/button.cpp index a2d84150a..b597368fe 100644 --- a/lib/gui/button.cpp +++ b/lib/gui/button.cpp @@ -20,10 +20,10 @@ #include "SDL.h" #include -#include "../gui/button.h" -#include "../gui/mousecursor.h" -#include "../app/globals.h" -#include "../video/font.h" +#include "button.h" +#include "mousecursor.h" +#include "app/globals.h" +#include "video/font.h" using namespace SuperTux; diff --git a/lib/gui/button.h b/lib/gui/button.h index 518edb3c2..5a78d4592 100644 --- a/lib/gui/button.h +++ b/lib/gui/button.h @@ -21,8 +21,8 @@ #include #include -#include "../math/vector.h" -#include "../video/drawing_context.h" +#include "math/vector.h" +#include "video/drawing_context.h" namespace SuperTux { diff --git a/lib/gui/menu.cpp b/lib/gui/menu.cpp index 3e65955c6..ba7b749a6 100644 --- a/lib/gui/menu.cpp +++ b/lib/gui/menu.cpp @@ -31,13 +31,13 @@ #include #include -#include "../app/globals.h" -#include "../gui/menu.h" -#include "../video/screen.h" -#include "../video/drawing_context.h" -#include "../app/setup.h" -#include "../app/gettext.h" -#include "../math/vector.h" +#include "app/globals.h" +#include "menu.h" +#include "video/screen.h" +#include "video/drawing_context.h" +#include "app/setup.h" +#include "app/gettext.h" +#include "math/vector.h" using namespace SuperTux; diff --git a/lib/gui/menu.h b/lib/gui/menu.h index f6d52aa61..c9ef6ee7b 100644 --- a/lib/gui/menu.h +++ b/lib/gui/menu.h @@ -27,10 +27,10 @@ #include "SDL.h" -#include "../video/surface.h" -#include "../video/font.h" -#include "../special/timer.h" -#include "../gui/mousecursor.h" +#include "video/surface.h" +#include "video/font.h" +#include "special/timer.h" +#include "mousecursor.h" namespace SuperTux { diff --git a/lib/gui/mousecursor.cpp b/lib/gui/mousecursor.cpp index e1e936be6..26df18db2 100644 --- a/lib/gui/mousecursor.cpp +++ b/lib/gui/mousecursor.cpp @@ -19,8 +19,8 @@ #include -#include "../video/drawing_context.h" -#include "../gui/mousecursor.h" +#include "video/drawing_context.h" +#include "gui/mousecursor.h" using namespace SuperTux; diff --git a/lib/gui/mousecursor.h b/lib/gui/mousecursor.h index c6b19f39b..0842b62c8 100644 --- a/lib/gui/mousecursor.h +++ b/lib/gui/mousecursor.h @@ -22,8 +22,8 @@ #include -#include "../special/timer.h" -#include "../video/surface.h" +#include "special/timer.h" +#include "video/surface.h" namespace SuperTux { diff --git a/lib/math/physic.cpp b/lib/math/physic.cpp index 7156aabd5..7cc570b97 100644 --- a/lib/math/physic.cpp +++ b/lib/math/physic.cpp @@ -22,8 +22,8 @@ #include -#include "../math/physic.h" -#include "../special/timer.h" +#include "math/physic.h" +#include "special/timer.h" using namespace SuperTux; diff --git a/lib/math/vector.cpp b/lib/math/vector.cpp index c156402fd..66a8352ab 100644 --- a/lib/math/vector.cpp +++ b/lib/math/vector.cpp @@ -21,7 +21,7 @@ #include -#include "../math/vector.h" +#include "math/vector.h" using namespace SuperTux; diff --git a/lib/special/collision.cpp b/lib/special/collision.cpp index b0cb2295d..1589a6e47 100644 --- a/lib/special/collision.cpp +++ b/lib/special/collision.cpp @@ -26,37 +26,38 @@ Collision::rectangle_rectangle(CollisionHit& hit, const Rectangle& r1, if(r1.p2.y < r2.p1.y || r1.p1.y > r2.p2.y) return false; - float xr; if(movement.x > DELTA) { hit.depth = r1.p2.x - r2.p1.x; + hit.time = hit.depth / movement.x; hit.normal.x = -1; hit.normal.y = 0; - xr = hit.depth / movement.x; } else if(movement.x < -DELTA) { hit.depth = r2.p2.x - r1.p1.x; + hit.time = hit.depth / -movement.x; hit.normal.x = 1; hit.normal.y = 0; - xr = hit.depth / -movement.x; } else { - xr = FLT_MAX; if(movement.y > -DELTA && movement.y < DELTA) { return false; } + hit.time = FLT_MAX; } if(movement.y > DELTA) { float ydepth = r1.p2.y - r2.p1.y; - float yr = ydepth / movement.y; - if(yr < xr) { + float yt = ydepth / movement.y; + if(yt < hit.time) { hit.depth = ydepth; + hit.time = yt; hit.normal.x = 0; hit.normal.y = -1; } } else if(movement.y < -DELTA) { float ydepth = r2.p2.y - r1.p1.y; - float yr = ydepth / -movement.y; - if(yr < xr) { + float yt = ydepth / -movement.y; + if(yt < hit.time) { hit.depth = ydepth; + hit.time = yt; hit.normal.x = 0; hit.normal.y = 1; } diff --git a/lib/special/collision_hit.h b/lib/special/collision_hit.h index 068965906..07974f629 100644 --- a/lib/special/collision_hit.h +++ b/lib/special/collision_hit.h @@ -44,7 +44,9 @@ class CollisionHit public: /// penetration depth float depth; - // The normal of the side we collided with + /// time of the collision (between 0 and 1 in relation to movement) + float time; + /// The normal of the side we collided with Vector normal; }; diff --git a/lib/special/frame_rate.cpp b/lib/special/frame_rate.cpp index 5c8c2b859..cff40710d 100644 --- a/lib/special/frame_rate.cpp +++ b/lib/special/frame_rate.cpp @@ -20,8 +20,8 @@ #include "SDL.h" -#include "../special/frame_rate.h" -#include "../special/timer.h" +#include "frame_rate.h" +#include "timer.h" using namespace SuperTux; diff --git a/lib/special/game_object.cpp b/lib/special/game_object.cpp index b525bac06..c3fd98dcd 100644 --- a/lib/special/game_object.cpp +++ b/lib/special/game_object.cpp @@ -19,7 +19,7 @@ #include -#include "../special/game_object.h" +#include "special/game_object.h" namespace SuperTux { diff --git a/lib/special/moving_object.cpp b/lib/special/moving_object.cpp index 46edc5aeb..8f543a91f 100644 --- a/lib/special/moving_object.cpp +++ b/lib/special/moving_object.cpp @@ -19,7 +19,7 @@ #include -#include "../special/moving_object.h" +#include "moving_object.h" using namespace SuperTux; diff --git a/lib/special/sprite.cpp b/lib/special/sprite.cpp index 080cc3e9e..c73dc3835 100644 --- a/lib/special/sprite.cpp +++ b/lib/special/sprite.cpp @@ -23,10 +23,10 @@ #include #include -#include "../app/globals.h" -#include "../app/setup.h" -#include "../special/sprite.h" -#include "../video/drawing_context.h" +#include "app/globals.h" +#include "app/setup.h" +#include "sprite.h" +#include "video/drawing_context.h" namespace SuperTux { diff --git a/lib/special/sprite.h b/lib/special/sprite.h index 2e18eb65b..655aba800 100644 --- a/lib/special/sprite.h +++ b/lib/special/sprite.h @@ -24,9 +24,9 @@ #include #include -#include "../utils/lispreader.h" -#include "../video/surface.h" -#include "../math/vector.h" +#include "utils/lispreader.h" +#include "video/surface.h" +#include "math/vector.h" #include "sprite_data.h" namespace SuperTux diff --git a/lib/special/sprite_data.cpp b/lib/special/sprite_data.cpp index 6289076fe..197b7c52b 100644 --- a/lib/special/sprite_data.cpp +++ b/lib/special/sprite_data.cpp @@ -23,10 +23,10 @@ #include #include -#include "../app/globals.h" -#include "../app/setup.h" -#include "../special/sprite.h" -#include "../video/drawing_context.h" +#include "sprite_data.h" +#include "app/globals.h" +#include "app/setup.h" +#include "video/drawing_context.h" namespace SuperTux { diff --git a/lib/special/sprite_data.h b/lib/special/sprite_data.h index a33cba74a..55d747311 100644 --- a/lib/special/sprite_data.h +++ b/lib/special/sprite_data.h @@ -24,8 +24,8 @@ #include #include -#include "../utils/lispreader.h" -#include "../video/surface.h" +#include "utils/lispreader.h" +#include "video/surface.h" namespace SuperTux { diff --git a/lib/special/sprite_manager.h b/lib/special/sprite_manager.h index bc2e1e6f6..2925e68df 100644 --- a/lib/special/sprite_manager.h +++ b/lib/special/sprite_manager.h @@ -22,7 +22,7 @@ #include -#include "../special/sprite.h" +#include "sprite.h" namespace SuperTux { diff --git a/lib/special/timer.cpp b/lib/special/timer.cpp index 5aa62bada..1ff134981 100644 --- a/lib/special/timer.cpp +++ b/lib/special/timer.cpp @@ -21,7 +21,7 @@ #include #include "SDL.h" -#include "../special/timer.h" +#include "timer.h" using namespace SuperTux; diff --git a/lib/utils/configfile.cpp b/lib/utils/configfile.cpp index 452f4cdbb..aa8cb401c 100644 --- a/lib/utils/configfile.cpp +++ b/lib/utils/configfile.cpp @@ -22,10 +22,10 @@ #include #include -#include "../utils/configfile.h" -#include "../app/setup.h" -#include "../app/globals.h" -#include "../audio/sound_manager.h" +#include "configfile.h" +#include "app/setup.h" +#include "app/globals.h" +#include "audio/sound_manager.h" using namespace SuperTux; diff --git a/lib/utils/configfile.h b/lib/utils/configfile.h index 17d1af2a1..6620bcb7b 100644 --- a/lib/utils/configfile.h +++ b/lib/utils/configfile.h @@ -20,7 +20,7 @@ #ifndef SUPERTUX_CONFIGFILE_H #define SUPERTUX_CONFIGFILE_H -#include "../utils/lispreader.h" +#include "lispreader.h" namespace SuperTux { diff --git a/lib/utils/lispreader.cpp b/lib/utils/lispreader.cpp index f435527f4..6076b16fe 100644 --- a/lib/utils/lispreader.cpp +++ b/lib/utils/lispreader.cpp @@ -31,9 +31,9 @@ #include #include -#include "../app/globals.h" -#include "../app/setup.h" -#include "../utils/lispreader.h" +#include "app/globals.h" +#include "app/setup.h" +#include "lispreader.h" using namespace SuperTux; diff --git a/lib/utils/lispreader.h b/lib/utils/lispreader.h index 704ff7829..ad8ed16f2 100644 --- a/lib/utils/lispreader.h +++ b/lib/utils/lispreader.h @@ -31,7 +31,7 @@ #include -#include "../utils/exceptions.h" +#include "utils/exceptions.h" namespace SuperTux { diff --git a/lib/utils/lispwriter.cpp b/lib/utils/lispwriter.cpp index 72e201de1..383927cb7 100644 --- a/lib/utils/lispwriter.cpp +++ b/lib/utils/lispwriter.cpp @@ -21,7 +21,7 @@ #include -#include "../utils/lispwriter.h" +#include "lispwriter.h" using namespace SuperTux; diff --git a/lib/video/drawing_context.cpp b/lib/video/drawing_context.cpp index 1b35337f0..bba6d36c2 100644 --- a/lib/video/drawing_context.cpp +++ b/lib/video/drawing_context.cpp @@ -22,10 +22,10 @@ #include #include -#include "../video/drawing_context.h" -#include "../video/surface.h" -#include "../app/globals.h" -#include "../video/font.h" +#include "drawing_context.h" +#include "surface.h" +#include "app/globals.h" +#include "font.h" using namespace SuperTux; diff --git a/lib/video/drawing_context.h b/lib/video/drawing_context.h index 03dce32e6..7ef8de954 100644 --- a/lib/video/drawing_context.h +++ b/lib/video/drawing_context.h @@ -24,9 +24,9 @@ #include "SDL.h" -#include "../math/vector.h" -#include "../video/screen.h" -#include "../video/surface.h" +#include "math/vector.h" +#include "video/screen.h" +#include "video/surface.h" namespace SuperTux { diff --git a/lib/video/font.cpp b/lib/video/font.cpp index 93e792568..78cfd39ab 100644 --- a/lib/video/font.cpp +++ b/lib/video/font.cpp @@ -23,11 +23,11 @@ #include #include -#include "../app/globals.h" -#include "../video/screen.h" -#include "../video/font.h" -#include "../video/drawing_context.h" -#include "../utils/lispreader.h" +#include "app/globals.h" +#include "screen.h" +#include "font.h" +#include "drawing_context.h" +#include "utils/lispreader.h" using namespace SuperTux; diff --git a/lib/video/font.h b/lib/video/font.h index 2a5067aff..429cf97e1 100644 --- a/lib/video/font.h +++ b/lib/video/font.h @@ -23,8 +23,8 @@ #include -#include "../video/surface.h" -#include "../math/vector.h" +#include "video/surface.h" +#include "math/vector.h" namespace SuperTux { diff --git a/lib/video/screen.cpp b/lib/video/screen.cpp index 2b6d23170..4cef05703 100644 --- a/lib/video/screen.cpp +++ b/lib/video/screen.cpp @@ -35,10 +35,10 @@ #include #endif -#include "../video/screen.h" -#include "../app/globals.h" -#include "../video/drawing_context.h" -#include "../math/vector.h" +#include "screen.h" +#include "app/globals.h" +#include "video/drawing_context.h" +#include "math/vector.h" using namespace SuperTux; diff --git a/lib/video/surface.cpp b/lib/video/surface.cpp index 5f51c871a..fafdec82b 100644 --- a/lib/video/surface.cpp +++ b/lib/video/surface.cpp @@ -27,10 +27,10 @@ #include "SDL.h" #include "SDL_image.h" -#include "../video/surface.h" -#include "../video/screen.h" -#include "../app/globals.h" -#include "../app/setup.h" +#include "video/surface.h" +#include "video/screen.h" +#include "app/globals.h" +#include "app/setup.h" using namespace SuperTux; diff --git a/lib/video/surface.h b/lib/video/surface.h index 1491e84fa..d13d9dc58 100644 --- a/lib/video/surface.h +++ b/lib/video/surface.h @@ -29,8 +29,8 @@ #include "SDL.h" -#include "../math/vector.h" -#include "../video/screen.h" +#include "math/vector.h" +#include "video/screen.h" namespace SuperTux { diff --git a/mk/jam/flags.jam b/mk/jam/flags.jam index 1b8ea6160..be214357c 100644 --- a/mk/jam/flags.jam +++ b/mk/jam/flags.jam @@ -124,7 +124,7 @@ rule ExtraObjects ## sure the dependency scanner is able to locate your header files. The ## directories are relative to the current subdir specified with the SubDir ## rule. -## Implementation: The directories are simply added to the HDRS variable +## Implementation: The directories are simply added to the HDRSEARCH variable ## which is respected by all jam rules. rule IncludeDir { @@ -136,14 +136,14 @@ rule IncludeDir CppFlags $(<) : [ CreateIncludeFlags $(dir) ] ; # needed for header scanning - HDRS on $($(<)_SOURCES) += $(dir) ; + HDRSEARCH on $($(<)_SOURCES) += $(dir) ; } } else { for i in $(<) { dir = [ ConcatDirs $(SUBDIR) $(i) ] ; CPPFLAGS += [ CreateIncludeFlags $(dir) ] ; # needed for header scanning - HDRS += $(dir) ; + HDRSEARCH += $(dir) ; } } } diff --git a/mk/jam/jamcompatibility.jam b/mk/jam/jamcompatibility.jam index 9cd0ce1a4..a0c09368f 100644 --- a/mk/jam/jamcompatibility.jam +++ b/mk/jam/jamcompatibility.jam @@ -220,7 +220,6 @@ rule SubDir # directory should not hold object files, LOCATE_TARGET can # subsequently be redefined. -#echo SS: $(SUBDIR) ; SEARCH_SOURCE = $(SUBDIR) ; LOCATE_SOURCE = $(ALL_LOCATE_TARGET) $(SUBDIR) ; LOCATE_TARGET = $(ALL_LOCATE_TARGET) $(SUBDIR) ; diff --git a/mk/jam/objects.jam b/mk/jam/objects.jam index aeec2506e..c9c024545 100644 --- a/mk/jam/objects.jam +++ b/mk/jam/objects.jam @@ -75,18 +75,15 @@ rule CompileObject # the regexp pattern $(HDRSCAN) and then invokes $(HDRRULE) # with the scanned file as the target and the found headers # as the sources. HDRSEARCH is the value of SEARCH used for - # the found header files. Finally, if jam must deal with - # header files of the same name in different directories, - # they can be distinguished with HDRGRIST. + # the found header files. # $(SEARCH_SOURCE:E) is where cc first looks for #include # "foo.h" files. If the source file is in a distant directory, # look there. Else, look in "" (the current directory). if $(HDRRULE_$(<:S)) { - HDRS on $(<) = [ ConcatDirs $(SUBDIR) $(<:D) ] - $(SEARCH_SOURCE:E) $(HDRS) $(STDHDRS) ; - HDRGRIST on $(<) = $(HDRGRIST) ; + HDRSEARCH on $(<) = $(SEARCH_SOURCE:E) $(HDRSEARCH) $(STDHDRSEARCH) ; + SEARCH_SOURCE on $(<) = $(SEARCH_SOURCE) ; HDRRULE on $(<) = $(HDRRULE_$(<:S)) ; HDRSCAN on $(<) = $(HDRPATTERN_$(<:S)) ; } @@ -125,19 +122,26 @@ rule HeaderRule # set SEARCH so Jam can find the headers, but then say we don't # care if we can't actually find the headers (they may have been # within ifdefs), - local s = $(>:G=$(HDRGRIST:E)) ; + local HDRSEARCH = [ on $(<) GetVar HDRSEARCH ] ; + local SEARCH_SOURCE = [ on $(<) GetVar SEARCH_SOURCE ] ; + + Includes $(<) : $(>) ; + SEARCH on $(>) = $(HDRSEARCH) $(SEARCH_SOURCE)/$(<:D) ; + NoCare $(>) ; - Includes $(<) : $(s) ; - SEARCH on $(s) = $(HDRS) ; - NoCare $(s) ; - local i ; - for i in $(s) + for i in $(>) { - HDRGRIST on $(s) = $(HDRGRIST) ; - HDRS on $(s) = $(HDRS) ; - HDRRULE on $(s) = [ on $(<) GetVar HDRRULE ] ; - HDRSCAN on $(s) = [ on $(<) GetVar HDRPATTERN ] ; + + SEARCH on $(>) = $(HDRSEARCH) $(SEARCH_SOURCE)/$(<:D) ; + if $(i:D) = "" { + SEARCH_SOURCE on $(i) = $(SEARCH_SOURCE)/$(<:D) ; + } else { + SEARCH_SOURCE on $(i) = $(SEARCH_SOURCE) ; + } + HDRSEARCH on $(>) = $(HDRSEARCH) ; + HDRRULE on $(>) = [ on $(<) GetVar HDRRULE ] ; + HDRSCAN on $(>) = [ on $(<) GetVar HDRPATTERN ] ; } } @@ -148,10 +152,10 @@ if $(JAMVERSION) < 2.5 rule HeaderRule { - local s = $(>:G=$(HDRGRIST:E)) ; + local s = $(>:G=$(HDRGRIST)) ; Includes $(<) : $(s) ; - SEARCH on $(s) = $(HDRS) ; + SEARCH on $(s) = $(HDRSEARCH) ; NoCare $(s) ; local i ; @@ -160,7 +164,7 @@ rule HeaderRule if $(HDRRULE_$(i:S)) { HDRGRIST on $(s) = $(HDRGRIST) ; - HDRS on $(s) = $(HDRS) ; + HDRSEARCH on $(s) = $(HDRSEARCH) ; HDRRULE on $(s) = $(HDRRULE_$(i:S)) ; HDRSCAN on $(s) = $(HDRPATTERN_$(i:S)) ; } diff --git a/mk/jam/variant.jam b/mk/jam/variant.jam index 2697579f5..e2c483de9 100644 --- a/mk/jam/variant.jam +++ b/mk/jam/variant.jam @@ -22,7 +22,7 @@ case profile : CCFLAGS += $(COMPILER_CFLAGS) $(COMPILER_CFLAGS_$(VARIANT)) ; C++FLAGS += $(COMPILER_CFLAGS) $(COMPILER_C++FLAGS) $(COMPILER_CFLAGS_$(VARIANT)) $(COMPILER_C++FLAGS_$(VARIANT)) ; -LINKLIBS += $(LDFLAGS) $(COMPILER_LFLAGS) $(COMPILER_LFLAGS_$(VARIANT)) ; +LFLAGS += $(LDFLAGS) $(COMPILER_LFLAGS) $(COMPILER_LFLAGS_$(VARIANT)) ; LOCATE_OBJECTS = $(LOCATE_OBJECTS)/$(SHORTVARIANT) ; ## SubVariant variantname diff --git a/src/gameloop.cpp b/src/gameloop.cpp index 15895653e..89776b069 100644 --- a/src/gameloop.cpp +++ b/src/gameloop.cpp @@ -723,6 +723,7 @@ GameSession::run() float elapsed_time = float(ticks - lastticks) / 1000.; global_time += elapsed_time; lastticks = ticks; + // 40fps is minimum if(elapsed_time > .025) elapsed_time = .025; diff --git a/src/object/block.cpp b/src/object/block.cpp index cc9c40001..c75c990fa 100644 --- a/src/object/block.cpp +++ b/src/object/block.cpp @@ -40,8 +40,7 @@ Block::collision(GameObject& other, const CollisionHit& hitdata) Player* player = dynamic_cast (&other); if(player) { // collided from below? - if(hitdata.normal.x == 0 && hitdata.normal.y < 0 - && player->get_movement().y < 0) { + if(hitdata.normal.x == 0 && hitdata.normal.y < 0) { hit(*player); } } @@ -132,7 +131,7 @@ BonusBlock::hit(Player& player) break; case 3: // star - sector->add_object(new Star(get_pos())); + sector->add_object(new Star(get_pos() + Vector(0, -32))); break; case 4: // 1up diff --git a/src/object/growup.cpp b/src/object/growup.cpp index a7f748214..deaaff168 100644 --- a/src/object/growup.cpp +++ b/src/object/growup.cpp @@ -35,7 +35,7 @@ HitResponse GrowUp::collision(GameObject& other, const CollisionHit& hit) { if(other.get_flags() & FLAG_SOLID) { - if(fabsf(hit.normal.y) > .5) { // roof + if(fabsf(hit.normal.y) > .5) { // roof or ground physic.set_velocity_y(0); } else { // bumped left or right physic.set_velocity_x(-physic.get_velocity_x()); diff --git a/src/player.cpp b/src/player.cpp index 6ad42c298..e50bdab2f 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -885,9 +885,9 @@ Player::collision(GameObject& other, const CollisionHit& hit) physic.set_velocity_y(.1); } - if(hit.normal.x != 0) { // hit on the side? - if(hit.normal.y > 0.6) // limits the slopes we can move up... - physic.set_velocity_x(0); + if(fabsf(hit.normal.x) > .5) { // hit on the side? + printf("s"); fflush(stdout); + physic.set_velocity_x(0); } return CONTINUE; diff --git a/src/sector.cpp b/src/sector.cpp index 0dd15884b..52f154b85 100644 --- a/src/sector.cpp +++ b/src/sector.cpp @@ -635,7 +635,7 @@ Sector::collision_tilemap(MovingObject* object, int depth) CollisionHit temphit, hit; Rectangle dest = object->get_bbox(); dest.move(object->movement); - hit.depth = -1; + hit.time = -1; // represents an invalid value for(int x = starttilex; x*32 < max_x; ++x) { for(int y = starttiley; y*32 < max_y; ++y) { const Tile* tile = solids->get_tile(x, y); @@ -670,14 +670,14 @@ Sector::collision_tilemap(MovingObject* object, int depth) if(Collision::rectangle_aatriangle(temphit, dest, object->movement, triangle)) { - if(temphit.depth > hit.depth) + if(temphit.time > hit.time) hit = temphit; } } else { // normal rectangular tile Rectangle rect(x*32, y*32, (x+1)*32, (y+1)*32); if(Collision::rectangle_rectangle(temphit, dest, object->movement, rect)) { - if(temphit.depth > hit.depth) + if(temphit.time > hit.time) hit = temphit; } } @@ -685,7 +685,7 @@ Sector::collision_tilemap(MovingObject* object, int depth) } // did we collide at all? - if(hit.depth < 0) + if(hit.time < 0) return; // call collision function @@ -698,7 +698,7 @@ Sector::collision_tilemap(MovingObject* object, int depth) return; } // move out of collision and try again - object->movement += hit.normal * (hit.depth + .001); + object->movement += hit.normal * (hit.depth + .05); collision_tilemap(object, depth+1); } @@ -714,7 +714,6 @@ Sector::collision_object(MovingObject* object1, MovingObject* object2) Vector movement = object1->get_movement() - object2->get_movement(); if(Collision::rectangle_rectangle(hit, dest1, movement, dest2)) { HitResponse response1 = object1->collision(*object2, hit); - Vector hitnormal1 = hit.normal; hit.normal *= -1; HitResponse response2 = object2->collision(*object1, hit); @@ -722,15 +721,15 @@ Sector::collision_object(MovingObject* object1, MovingObject* object2) if(response1 == ABORT_MOVE) object1->movement = Vector(0, 0); if(response2 == CONTINUE) - object2->movement += hit.normal * (hit.depth + .1); + object2->movement += hit.normal * (hit.depth + .05); } else if(response2 != CONTINUE) { if(response2 == ABORT_MOVE) object2->movement = Vector(0, 0); if(response1 == CONTINUE) - object1->movement += hitnormal1 * (hit.depth + .1); + object1->movement += -hit.normal * (hit.depth + .05); } else { - object1->movement += hitnormal1 * (hit.depth/2 + 1); - object2->movement += hit.normal * (hit.depth/2 + 1); + object1->movement += -hit.normal * (hit.depth/2 + .05); + object2->movement += hit.normal * (hit.depth/2 + .05); } } }