Fixed Movement, now slide along walls instead of stopping immediately. Also fixed error where chunks don't load their collision
This commit is contained in:
@@ -21,24 +21,31 @@ namespace Collector.Character
|
||||
{
|
||||
X = x;
|
||||
Y = y;
|
||||
PlayerBounds = new RectangleF(x,y, IRestrictions.TileSize*0.5f, IRestrictions.TileSize*0.35f);
|
||||
PlayerBounds = new RectangleF(x, y, IRestrictions.TileSize * 0.5f, IRestrictions.TileSize * 0.35f);
|
||||
}
|
||||
|
||||
public static void Move(OrthographicCamera cam, float x, float y)
|
||||
{
|
||||
Teleport(cam, x, 0);
|
||||
if (Chunks.LoadedCollisions.Values.Any(collisionsValue => collisionsValue.Rectangle.Intersects(PlayerBounds)))
|
||||
{
|
||||
Teleport(cam, -x, 0);
|
||||
}
|
||||
|
||||
Teleport(cam, 0, y);
|
||||
if (Chunks.LoadedCollisions.Values.Any(collisionsValue => collisionsValue.Rectangle.Intersects(PlayerBounds)))
|
||||
{
|
||||
Teleport(cam, 0, -y);
|
||||
}
|
||||
}
|
||||
|
||||
private static void Teleport(OrthographicCamera cam, float x, float y)
|
||||
{
|
||||
X += x;
|
||||
Y += y;
|
||||
PlayerBounds.X = X+0.2f;
|
||||
PlayerBounds.Y = Y+1.5f;
|
||||
|
||||
PlayerBounds.X = X + 0.2f;
|
||||
PlayerBounds.Y = Y + 1.5f;
|
||||
cam.Move(new Vector2(x, y));
|
||||
if (!Chunks.loadedCollisions.Values.Any(collisionsValue => collisionsValue.Rectangle.Intersects(PlayerBounds))) return;
|
||||
|
||||
X -= x;
|
||||
Y -= y;
|
||||
cam.Move(new Vector2(-x, -y));
|
||||
PlayerBounds.X -= X;
|
||||
PlayerBounds.Y -= Y;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user