sneak/Jumpy.Shared/Camera.cs
Colin McMillen 22db0ee696 basic scrolling world!
GitOrigin-RevId: 6c08535f1ace172f9f08479ced5e9dc8b0663102
2020-02-13 14:47:59 -05:00

25 lines
668 B
C#

using Microsoft.Xna.Framework;
using System;
namespace Jumpy {
class Camera {
private Rectangle bbox = new Rectangle(0, 0, 1920 / 6, 1080 / 6);
public int Width { get => bbox.Width; }
public int Height { get => bbox.Height; }
public int Left { get => bbox.Left; }
public void Update(GameTime time, Point player) {
int diff = player.X - bbox.Center.X;
// TODO: use the actual center of the player's bbox.
if (Math.Abs(diff) > 16) {
bbox.Offset((int) (diff * 0.1), 0);
}
if (bbox.Left < 0) {
bbox.Offset(-bbox.Left, 0);
}
Debug.Toast($"p: {player.X} c: {bbox.Center.X}");
}
}
}