sneak/Shared/Camera.cs
Colin McMillen 710d1042ab remove TODO
GitOrigin-RevId: 91ae9789334d2e1096a2a75cde49e8e48472d8f6
2020-02-13 14:48:47 -05:00

26 lines
795 B
C#

using Microsoft.Xna.Framework;
using System;
// Good background reading, eventually:
// https://gamasutra.com/blogs/ItayKeren/20150511/243083/Scroll_Back_The_Theory_and_Practice_of_Cameras_in_SideScrollers.php
namespace SemiColinGames {
class Camera {
private Rectangle bbox = new Rectangle(0, 0, 1920 / 4, 1080 / 4);
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;
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}, {player.Y} c: {bbox.Center.X}");
}
}
}