2021-03-07 22:23:51 +01:00
|
|
|
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; }
|
2021-03-08 02:37:40 +01:00
|
|
|
public Camera Camera { get; private set; }
|
2021-03-07 22:23:51 +01:00
|
|
|
|
|
|
|
public GameImpl() {
|
|
|
|
Instance = this;
|
2021-03-08 02:37:40 +01:00
|
|
|
this.IsMouseVisible = true;
|
2021-03-07 22:23:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
protected override void LoadContent() {
|
|
|
|
this.GraphicsDeviceManager.PreferredBackBufferWidth = 1280;
|
|
|
|
this.GraphicsDeviceManager.PreferredBackBufferHeight = 720;
|
|
|
|
this.GraphicsDeviceManager.ApplyChanges();
|
|
|
|
base.LoadContent();
|
|
|
|
this.InputHandler.HandleKeyboardRepeats = false;
|
|
|
|
|
2021-03-08 02:37:40 +01:00
|
|
|
this.Camera = new Camera(this.GraphicsDevice) {
|
2021-03-07 22:23:51 +01:00
|
|
|
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);
|
2021-03-08 02:37:40 +01:00
|
|
|
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());
|
2021-03-07 22:23:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
protected override void DoDraw(GameTime gameTime) {
|
|
|
|
this.GraphicsDevice.Clear(Color.CornflowerBlue);
|
|
|
|
base.DoDraw(gameTime);
|
2021-03-08 02:37:40 +01:00
|
|
|
this.Map.Draw(gameTime, this.SpriteBatch, this.Camera);
|
2021-03-07 22:23:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|