using System; using System.Collections.Generic; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Input; using TankBattleCore.Objects; namespace TankBattleCore; internal enum TankColor { Black } public class Game1 : Game { private static Game1 _instance; public static Game1 Instance { get { if (_instance == null) { _instance = new Game1(); } return _instance; } } private GraphicsDeviceManager _graphics; private SpriteBatch _spriteBatch; internal Dictionary TankBodyTextures { get; private set; } IScene _scene; public int WindowWidth { get => _graphics.PreferredBackBufferWidth; } public int WindowHeight { get => _graphics.PreferredBackBufferHeight; } private Game1() { _graphics = new GraphicsDeviceManager(this); Content.RootDirectory = "Content"; IsMouseVisible = true; } protected override void Initialize() { base.Initialize(); } protected override void LoadContent() { _spriteBatch = new SpriteBatch(GraphicsDevice); TankBodyTextures = new Dictionary() { {TankColor.Black, Content.Load("tankBlack_outline")} }; _scene = new GameScene(); } protected override void Update(GameTime gameTime) { if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape)) Exit(); float dt = (float)gameTime.ElapsedGameTime.TotalSeconds; _scene.Update(dt); base.Update(gameTime); } protected override void Draw(GameTime gameTime) { GraphicsDevice.Clear(Color.CornflowerBlue); _scene.Draw(_spriteBatch); base.Draw(gameTime); } }