(time 999)
(sector
(name "main")
- (width 30)
- (height 30)
(gravity 10.000000)
(background (image "arctis.jpg")
(speed 0.5))
#include "SDL.h"
-#include "../video/font.h"
+#include "video/font.h"
#include "tinygettext.h"
namespace SuperTux
#include <cctype>
-#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;
#include <config.h>
-#include "../audio/musicref.h"
+#include "audio/musicref.h"
using namespace SuperTux;
#ifndef SUPERTUX_MUSICREF_H
#define SUPERTUX_MUSICREF_H
-#include "../audio/sound_manager.h"
+#include "sound_manager.h"
namespace SuperTux
{
#include <cmath>
#include <cassert>
-#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;
#include <map>
#include "SDL_mixer.h"
-#include "../math/vector.h"
+#include "math/vector.h"
namespace SuperTux
{
#include "SDL.h"
#include <iostream>
-#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;
#include <vector>
#include <string>
-#include "../math/vector.h"
-#include "../video/drawing_context.h"
+#include "math/vector.h"
+#include "video/drawing_context.h"
namespace SuperTux
{
#include <string>
#include <cassert>
-#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;
#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
{
#include <config.h>
-#include "../video/drawing_context.h"
-#include "../gui/mousecursor.h"
+#include "video/drawing_context.h"
+#include "gui/mousecursor.h"
using namespace SuperTux;
#include <string>
-#include "../special/timer.h"
-#include "../video/surface.h"
+#include "special/timer.h"
+#include "video/surface.h"
namespace SuperTux
{
#include <cstdio>
-#include "../math/physic.h"
-#include "../special/timer.h"
+#include "math/physic.h"
+#include "special/timer.h"
using namespace SuperTux;
#include <cmath>
-#include "../math/vector.h"
+#include "math/vector.h"
using namespace SuperTux;
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;
}
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;
};
#include "SDL.h"
-#include "../special/frame_rate.h"
-#include "../special/timer.h"
+#include "frame_rate.h"
+#include "timer.h"
using namespace SuperTux;
#include <config.h>
-#include "../special/game_object.h"
+#include "special/game_object.h"
namespace SuperTux
{
#include <config.h>
-#include "../special/moving_object.h"
+#include "moving_object.h"
using namespace SuperTux;
#include <cassert>
#include <stdexcept>
-#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
{
#include <vector>
#include <map>
-#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
#include <sstream>
#include <stdexcept>
-#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
{
#include <vector>
#include <map>
-#include "../utils/lispreader.h"
-#include "../video/surface.h"
+#include "utils/lispreader.h"
+#include "video/surface.h"
namespace SuperTux
{
#include <map>
-#include "../special/sprite.h"
+#include "sprite.h"
namespace SuperTux
{
#include <config.h>
#include "SDL.h"
-#include "../special/timer.h"
+#include "timer.h"
using namespace SuperTux;
#include <cstdlib>
#include <string>
-#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;
#ifndef SUPERTUX_CONFIGFILE_H
#define SUPERTUX_CONFIGFILE_H
-#include "../utils/lispreader.h"
+#include "lispreader.h"
namespace SuperTux {
#include <cstring>
#include <cassert>
-#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;
#include <zlib.h>
-#include "../utils/exceptions.h"
+#include "utils/exceptions.h"
namespace SuperTux {
#include <iostream>
-#include "../utils/lispwriter.h"
+#include "lispwriter.h"
using namespace SuperTux;
#include <cassert>
#include <iostream>
-#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;
#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
{
#include <cstdlib>
#include <cstring>
-#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;
#include <string>
-#include "../video/surface.h"
-#include "../math/vector.h"
+#include "video/surface.h"
+#include "math/vector.h"
namespace SuperTux
{
#include <ctype.h>
#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;
#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;
#include "SDL.h"
-#include "../math/vector.h"
-#include "../video/screen.h"
+#include "math/vector.h"
+#include "video/screen.h"
namespace SuperTux
{
## 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
{
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) ;
}
}
}
# 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) ;
# 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)) ;
}
# 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 ] ;
}
}
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 ;
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)) ;
}
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
float elapsed_time = float(ticks - lastticks) / 1000.;
global_time += elapsed_time;
lastticks = ticks;
+
// 40fps is minimum
if(elapsed_time > .025)
elapsed_time = .025;
Player* player = dynamic_cast<Player*> (&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);
}
}
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
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());
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;
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);
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;
}
}
}
// did we collide at all?
- if(hit.depth < 0)
+ if(hit.time < 0)
return;
// call collision function
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);
}
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);
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);
}
}
}