|
|
@ -21,22 +21,31 @@ namespace SemiColinGames { |
|
|
|
get => Matrix.CreateOrthographicOffCenter(Left, Left + Width, Height + Top, Top, -1, 1); |
|
|
|
} |
|
|
|
|
|
|
|
public void Update(float modelTime, Player player, int worldWidth) { |
|
|
|
public void Update(float modelTime, Player player, int worldWidth, int worldHeight) { |
|
|
|
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) { |
|
|
|
if (player.StandingOnGround) { |
|
|
|
bbox.Offset(0, (int) (yDiff * 0.1)); |
|
|
|
} |
|
|
|
if (yDiff > 16) { |
|
|
|
bbox.Offset(0, (int) (yDiff * 0.2)); |
|
|
|
} |
|
|
|
if (bbox.Left < 0) { |
|
|
|
bbox.Offset(-bbox.Left, 0); |
|
|
|
} |
|
|
|
if (bbox.Right > worldWidth) { |
|
|
|
bbox.Offset(worldWidth - bbox.Right, 0); |
|
|
|
} |
|
|
|
if (bbox.Top < 0) { |
|
|
|
bbox.Offset(0, -bbox.Top); |
|
|
|
} |
|
|
|
if (bbox.Bottom > worldHeight) { |
|
|
|
bbox.Offset(0, worldHeight - bbox.Bottom); |
|
|
|
} |
|
|
|
if (shakeTime > 0) { |
|
|
|
shakeTime -= modelTime; |
|
|
|
int x = random.Next(-4, 5); |
|
|
|