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; } private Camera camera; public GameImpl() { Instance = this; } 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.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); } } }