|
|
@ -13,11 +13,14 @@ namespace SemiColinGames { |
|
|
|
public int Top { get => bbox.Top; } |
|
|
|
public Point HalfSize { get => new Point(Width / 2, Height / 2); } |
|
|
|
|
|
|
|
private float shakeTime = 0.0f; |
|
|
|
private Random random = new Random(); |
|
|
|
|
|
|
|
public Matrix Projection { |
|
|
|
get => Matrix.CreateOrthographicOffCenter(Left, Left + Width, Height, 0, -1, 1); |
|
|
|
} |
|
|
|
|
|
|
|
public void Update(Point player, int worldWidth) { |
|
|
|
public void Update(float modelTime, Point player, int worldWidth) { |
|
|
|
int diff = player.X - bbox.Center.X; |
|
|
|
if (Math.Abs(diff) > 16) { |
|
|
|
bbox.Offset((int) (diff * 0.1), 0); |
|
|
@ -28,7 +31,16 @@ namespace SemiColinGames { |
|
|
|
if (bbox.Right > worldWidth) { |
|
|
|
bbox.Offset(worldWidth - bbox.Right, 0); |
|
|
|
} |
|
|
|
if (shakeTime > 0) { |
|
|
|
shakeTime -= modelTime; |
|
|
|
int x = random.Next(-4, 5); |
|
|
|
bbox.Offset(x, 0); |
|
|
|
} |
|
|
|
Debug.AddToast($"p: {player.X}, {player.Y} c: {bbox.Center.X}"); |
|
|
|
} |
|
|
|
|
|
|
|
public void Shake() { |
|
|
|
shakeTime = 0.5f; |
|
|
|
} |
|
|
|
} |
|
|
|
} |