using Microsoft.Xna.Framework; using MLEM.Cameras; using MLEM.Startup; namespace GreatSpringGameJam { public class GameImpl : MlemGame { public static GameImpl Instance { get; private set; } public Map Map { get; private set; } public Player Player { get; private set; } public Camera Camera { get; private set; } public GameImpl() { Instance = this; this.IsMouseVisible = true; } protected override void LoadContent() { this.GraphicsDeviceManager.PreferredBackBufferWidth = 1280; this.GraphicsDeviceManager.PreferredBackBufferHeight = 720; this.GraphicsDeviceManager.ApplyChanges(); base.LoadContent(); this.InputHandler.HandleKeyboardRepeats = false; this.Camera = new Camera(this.GraphicsDevice) { AutoScaleWithScreen = true, Scale = 4, Position = new Vector2(0, float.MaxValue) }; this.Map = new Map("Level1"); this.Player = new Player(this.Map, new Vector2(5, 20)); this.Map.AddEntity(this.Player); } protected override void DoUpdate(GameTime gameTime) { base.DoUpdate(gameTime); this.Map.Update(gameTime); this.Camera.LookingPosition = Vector2.Lerp(this.Camera.LookingPosition, (this.Player.Position + Vector2.One / 2) * this.Map.TileSize, 0.25F); this.Camera.ConstrainWorldBounds(Vector2.Zero, this.Map.SizeInPixels.ToVector2()); } protected override void DoDraw(GameTime gameTime) { this.GraphicsDevice.Clear(Color.CornflowerBlue); base.DoDraw(gameTime); this.Map.Draw(gameTime, this.SpriteBatch, this.Camera); } } }