From 25fdc90968a14ffd44dae65d6fdb3d50e6df9082 Mon Sep 17 00:00:00 2001 From: BoredGuy Date: Fri, 27 Mar 2026 16:29:32 -0700 Subject: Initial Commit --- TankBattleCore/Game1.cs | 91 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 TankBattleCore/Game1.cs (limited to 'TankBattleCore/Game1.cs') diff --git a/TankBattleCore/Game1.cs b/TankBattleCore/Game1.cs new file mode 100644 index 0000000..91a09b5 --- /dev/null +++ b/TankBattleCore/Game1.cs @@ -0,0 +1,91 @@ +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); + } +} -- cgit v1.2.3