using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Input; using Microsoft.Xna.Framework.Audio; using Microsoft.Xna.Framework.Media; using System; using System.Collections.Generic; using System.Runtime.CompilerServices; namespace LunaLightXMG { public class LunaLightGame : Game { // Class Objects private Player player; private PlayerInput playerInput; private List enemies; private int numOfEnemies; private GraphicsDeviceManager graphics; private Camera2D camera2D; private SpriteBatch spriteBatch; // Native retro scale private int retroWidth = 320; private int retroHeight = 180; // Test Render Target Handler private RenderHandler renderHandler; bool resizing; // Test sprites - eventually handle in a sprite manager? private Texture2D platformTexture; private Texture2D sinkArea; // Test platforms private Platform[] platforms; private int numOfPlatforms; // Level Object private Level level; // Music private SoundEffect sinkBeats; private SoundEffectInstance backgroundMusicInstance; // Debugging private SpriteFont debugFont; private Texture2D debugGrid; // Keyboard input private KeyboardState prevKeyState; // Util Utilities util; public LunaLightGame() { graphics = new GraphicsDeviceManager(this); Content.RootDirectory = "Content"; IsMouseVisible = true; Window.ClientSizeChanged += OnClientSizeChanged; Window.AllowUserResizing = true; IsMouseVisible = true; playerInput = new PlayerInput(); //level = new Level(spriteBatch, renderHandler); } protected override void Initialize() { // Set initial window size graphics.PreferredBackBufferWidth = 1920; graphics.PreferredBackBufferHeight = 1080; graphics.ApplyChanges(); playerInput.HasControl = true; // May need to find a new home for this base.Initialize(); } protected override void LoadContent() { spriteBatch = new SpriteBatch(GraphicsDevice); renderHandler = new RenderHandler(GraphicsDevice, spriteBatch, retroWidth, retroHeight); if (level != null) level.Dispose(); level = new Level(spriteBatch, renderHandler); } protected override void Update(GameTime gameTime) { level.Update(gameTime); base.Update(gameTime); } protected override void Draw(GameTime gameTime) { GraphicsDevice.Clear(Color.CornflowerBlue); level.Draw(gameTime, spriteBatch); base.Draw(gameTime); } #region Methods private void OnClientSizeChanged(object sender, EventArgs eventArgs) { if (!resizing && Window.ClientBounds.Width > 0 && Window.ClientBounds.Height > 0) { resizing = true; renderHandler.CalculateRenderDestination(); resizing = false; } } #endregion } }