Compare commits

..

No commits in common. "10c2a86febea8fd07b4702cd0815af75e73eb9be" and "3be37740f7dbf3c58f1c1ec0c811ea200cd996ce" have entirely different histories.

3 changed files with 12 additions and 21 deletions

View File

@ -18,18 +18,13 @@ namespace SemiColinGames {
public Matrix Projection {
get => Matrix.CreateOrthographicOffCenter(Left, Left + Width, Height + Top, Top, -1, 1);
get => Matrix.CreateOrthographicOffCenter(Left, Left + Width, Height, 0, -1, 1);
}
public void Update(float modelTime, Player player, int worldWidth) {
Vector2 pos = player.Position;
float xDiff = pos.X - bbox.Center.X;
float yDiff = pos.Y - bbox.Center.Y;
if (Math.Abs(xDiff) > 16) {
bbox.Offset((int) (xDiff * 0.1), 0);
}
if (Math.Abs(yDiff) > 16 && player.StandingOnGround) {
bbox.Offset(0, (int) (yDiff * 0.1));
public void Update(float modelTime, Vector2 player, int worldWidth) {
float diff = player.X - bbox.Center.X;
if (Math.Abs(diff) > 16) {
bbox.Offset((int) (diff * 0.1), 0);
}
if (bbox.Left < 0) {
bbox.Offset(-bbox.Left, 0);
@ -40,14 +35,13 @@ namespace SemiColinGames {
if (shakeTime > 0) {
shakeTime -= modelTime;
int x = random.Next(-4, 5);
int y = random.Next(-4, 5);
bbox.Offset(x, y);
bbox.Offset(x, 0);
}
Debug.AddToast($"p: {pos.X}, {pos.Y} c: {bbox.Center.X}");
Debug.AddToast($"p: {player.X}, {player.Y} c: {bbox.Center.X}");
}
public void Shake() {
shakeTime = 0.3f;
shakeTime = 0.5f;
}
}
}

View File

@ -44,11 +44,8 @@ namespace SemiColinGames {
this.position = position;
Facing = facing;
Health = MaxHealth;
StandingOnGround = false;
}
public bool StandingOnGround { get; private set; }
public int MaxHealth { get; private set; } = 3;
public int Health { get; private set; }
@ -132,12 +129,12 @@ namespace SemiColinGames {
}
}
StandingOnGround = false;
bool standingOnGround = false;
AABB groundIntersect = BoxOffset(position, 1);
foreach (var box in candidates) {
if (groundIntersect.Intersect(box) != null) {
Debug.AddRect(box, Color.Cyan);
StandingOnGround = true;
standingOnGround = true;
if (box.Tile?.IsHazard ?? false) {
Debug.AddRect(box, Color.Red);
harmedByCollision = true;
@ -145,7 +142,7 @@ namespace SemiColinGames {
}
}
if (StandingOnGround) {
if (standingOnGround) {
jumps = 1;
ySpeed = -0.0001f;
Debug.AddRect(Box(position), Color.Cyan);

View File

@ -162,7 +162,7 @@ namespace SemiColinGames {
Reset();
}
LinesOfSight.Update(npcs, CollisionTargets);
Camera.Update(modelTime, Player, Width);
Camera.Update(modelTime, Player.Position, Width);
}
public void ScreenShake() {