--- /dev/null
+;;Uses 01 - Welcome to Antartica.stl as base\r
+(supertux-level\r
+ (version 2)\r
+ (name (_ "Demonstrates two tilemap platforms."))\r
+ (author "Mathnerd314")\r
+ (sector\r
+ (name "main")\r
+ (music "music/chipdisko.ogg")\r
+ (init-script "platform1.start_moving();platform2.start_moving();") ;needed for some reason (they don't move initially)\r
+ (ambient-light 1 1 1)\r
+ (spawnpoint\r
+ (name "main")\r
+ (x 100)\r
+ (y 100)\r
+ )\r
+ (background\r
+ (speed 0.5)\r
+ (image "images/background/arctis.jpg")\r
+ )\r
+ (tilemap\r
+ (z-pos -100)\r
+ (solid #f)\r
+ (speed 1)\r
+ (width 27)\r
+ (height 19)\r
+ (tiles\r
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \r
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \r
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \r
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \r
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \r
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \r
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \r
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \r
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \r
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \r
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \r
+0 0 0 0 0 0 0 0 0 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r
+ 16 17 17 17 18\r
+ )\r
+ )\r
+ (tilemap\r
+ (name "platform2")\r
+ (z-pos 2)\r
+ (solid #t)\r
+ (speed 1)\r
+ (speed-y 1)\r
+ (path\r
+ (mode "circular")\r
+ (node\r
+ (x 86)\r
+ (y 450)\r
+ (time 1)\r
+ )\r
+ (node\r
+ (x 200)\r
+ (y 450)\r
+ (time 1)\r
+ )\r
+ )\r
+ (width 5)\r
+ (height 1)\r
+ (tiles\r
+ 27 28 28 28 29\r
+ )\r
+ )\r
+ (camera\r
+ (mode "normal")\r
+ )\r
+ )\r
+)\r
}
bool rectangle_aatriangle(Constraints* constraints, const Rect& rect,
- const AATriangle& triangle)
+ const AATriangle& triangle, const Vector& addl_ground_movement)
{
if(!intersects(rect, (const Rect&) triangle))
return false;
if(outvec.y < 0) {
constraints->bottom = rect.get_bottom() + outvec.y;
constraints->hit.bottom = true;
+ constraints->ground_movement += addl_ground_movement;
} else {
constraints->top = rect.get_top() + outvec.y;
constraints->hit.top = true;
}
void set_rectangle_rectangle_constraints(Constraints* constraints,
- const Rect& r1, const Rect& r2)
+ const Rect& r1, const Rect& r2, const Vector& addl_ground_movement)
{
float itop = r1.get_bottom() - r2.get_top();
float ibottom = r2.get_bottom() - r1.get_top();
if(itop < ibottom) {
constraints->bottom = std::min(constraints->bottom, r2.get_top());
constraints->hit.bottom = true;
+ constraints->ground_movement += addl_ground_movement;
} else {
constraints->top = std::max(constraints->top, r2.get_bottom());
constraints->hit.top = true;
* Returns true in case of a collision and fills in the hit structure then.
*/
bool rectangle_aatriangle(Constraints* constraints, const Rect& rect,
- const AATriangle& triangle);
+ const AATriangle& triangle, const Vector& addl_ground_movement = Vector(0,0));
void set_rectangle_rectangle_constraints(Constraints* constraints,
- const Rect& r1, const Rect& r2);
+ const Rect& r1, const Rect& r2, const Vector& addl_ground_movement = Vector(0,0));
}
TileMap::TileMap(const TileSet *new_tileset)
: tileset(new_tileset), solid(false), speed_x(1), speed_y(1), width(0),
- height(0), z_pos(0), x_offset(0), y_offset(0), drawing_effect(NO_EFFECT),
+ height(0), z_pos(0), x_offset(0), y_offset(0), movement(Vector(0,0)), drawing_effect(NO_EFFECT),
alpha(1.0), current_alpha(1.0), remaining_fade_time(0),
draw_target(DrawingContext::NORMAL)
{
TileMap::TileMap(const lisp::Lisp& reader)
: solid(false), speed_x(1), speed_y(1), width(-1),
- height(-1), z_pos(0), x_offset(0), y_offset(0), drawing_effect(NO_EFFECT),
+ height(-1), z_pos(0), x_offset(0), y_offset(0), movement(Vector(0,0)), drawing_effect(NO_EFFECT),
alpha(1.0), current_alpha(1.0), remaining_fade_time(0),
draw_target(DrawingContext::NORMAL)
{
TileMap::TileMap(const TileSet *new_tileset, std::string name, int z_pos,
bool solid, size_t width, size_t height)
: tileset(new_tileset), solid(solid), speed_x(1), speed_y(1), width(0),
- height(0), z_pos(z_pos), x_offset(0), y_offset(0),
+ height(0), z_pos(z_pos), x_offset(0), y_offset(0), movement(Vector(0,0)),
drawing_effect(NO_EFFECT), alpha(1.0), current_alpha(1.0),
remaining_fade_time(0), draw_target(DrawingContext::NORMAL)
{
if ((alpha > 0.75) && (current_alpha > 0.75)) set_solid(true);
}
+ movement = Vector(0,0);
// if we have a path to follow, follow it
if (walker.get()) {
Vector v = walker->advance(elapsed_time);
+ movement = Vector(v.x-get_x_offset(), std::max(0.0f,v.y-get_y_offset()));
set_x_offset(v.x);
set_y_offset(v.y);
}
float get_y_offset() const
{ return y_offset; }
+ const Vector& get_movement() const
+ {
+ return movement;
+ }
+
void set_x_offset(float x_offset)
{ this->x_offset = x_offset; }
int z_pos;
float x_offset;
float y_offset;
+ Vector movement; /**< The movement that happened last frame */
DrawingEffect drawing_effect;
float alpha; /**< requested tilemap opacity */
/** r1 is supposed to be moving, r2 a solid object */
void check_collisions(collision::Constraints* constraints,
const Vector& movement, const Rect& r1, const Rect& r2,
- GameObject* object = NULL, MovingObject* other = NULL)
+ GameObject* object = NULL, MovingObject* other = NULL, const Vector& addl_ground_movement = Vector(0,0))
{
if(!collision::intersects(r1, r2))
return;
}
}
+ constraints->ground_movement += addl_ground_movement;
if(other != NULL) {
HitResponse response = other->collision(*object, dummy);
if(response == PASSTHROUGH)
if(other->get_movement() != Vector(0, 0)) {
// TODO what todo when we collide with 2 moving objects?!?
- constraints->ground_movement = other->get_movement();
+ constraints->ground_movement += other->get_movement();
}
}
Vector p2((x+1)*32 + solids->get_x_offset(), (y+1)*32 + solids->get_y_offset());
triangle = AATriangle(p1, p2, tile->getData());
- collision::rectangle_aatriangle(constraints, dest, triangle);
+ collision::rectangle_aatriangle(constraints, dest, triangle, solids->get_movement());
} else { // normal rectangular tile
Rect rect(x*32 + solids->get_x_offset(), y*32 + solids->get_y_offset(), (x+1)*32 + solids->get_x_offset(), (y+1)*32 + solids->get_y_offset());
- check_collisions(constraints, movement, dest, rect);
+ check_collisions(constraints, movement, dest, rect, NULL, NULL, solids->get_movement());
}
}
}