|
|
@@ -4,7 +4,7 @@ |
|
|
|
|
|
|
|
namespace Swan { |
|
|
|
|
|
|
|
static float epsilon = 0.0001; |
|
|
|
static float epsilon = 0.05; |
|
|
|
|
|
|
|
static void collideX( |
|
|
|
PhysicsTrait::Physics &phys, BodyTrait::Body &body, |
|
|
@@ -12,7 +12,7 @@ static void collideX( |
|
|
|
bool collided = false; |
|
|
|
|
|
|
|
for (int y = (int)floor(body.top() + epsilon); y <= (int)floor(body.bottom() - epsilon); ++y) { |
|
|
|
int lx = (int)floor(body.left() + epsilon); |
|
|
|
int lx = (int)floor(body.left()); |
|
|
|
Tile &left = plane.getTile({lx, y}); |
|
|
|
if (left.isSolid) { |
|
|
|
body.pos.x = (float)lx + 1.0; |
|
|
@@ -20,7 +20,7 @@ static void collideX( |
|
|
|
break; |
|
|
|
} |
|
|
|
|
|
|
|
int rx = (int)floor(body.right() - epsilon); |
|
|
|
int rx = (int)floor(body.right()); |
|
|
|
Tile &right = plane.getTile({rx, y}); |
|
|
|
if (right.isSolid) { |
|
|
|
body.pos.x = (float)rx - body.size.x; |
|
|
@@ -43,7 +43,7 @@ static void collideY( |
|
|
|
phys.onGround = false; |
|
|
|
|
|
|
|
for (int x = (int)floor(body.left() + epsilon); x <= (int)floor(body.right() - epsilon); ++x) { |
|
|
|
int ty = (int)floor(body.top() + epsilon); |
|
|
|
int ty = (int)floor(body.top()); |
|
|
|
Tile &top = plane.getTile({x, ty}); |
|
|
|
if (top.isSolid) { |
|
|
|
body.pos.y = (float)ty + 1.0; |
|
|
@@ -51,7 +51,7 @@ static void collideY( |
|
|
|
break; |
|
|
|
} |
|
|
|
|
|
|
|
int by = (int)floor(body.bottom() - epsilon); |
|
|
|
int by = (int)floor(body.bottom()); |
|
|
|
Tile &bottom = plane.getTile({x, by}); |
|
|
|
if (bottom.isSolid) { |
|
|
|
body.pos.y = (float)by - body.size.y; |