From 8ec918ca0456dfb911d41aa812941fecc6094c91 Mon Sep 17 00:00:00 2001 From: Syntriax Date: Mon, 27 Nov 2023 17:41:21 +0300 Subject: [PATCH] chore: Compiler Warnings Fixed --- Game/Behaviours/MovementBoxBehaviour.cs | 4 +++- Game/Game1.cs | 8 ++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Game/Behaviours/MovementBoxBehaviour.cs b/Game/Behaviours/MovementBoxBehaviour.cs index b31360e..e662cc5 100644 --- a/Game/Behaviours/MovementBoxBehaviour.cs +++ b/Game/Behaviours/MovementBoxBehaviour.cs @@ -34,9 +34,11 @@ public class MovementBoxBehaviour(Keys Up, Keys Down, float High, float Low, flo protected override void OnInitialize() { - if (!BehaviourController.TryGetBehaviour(out inputs)) + if (!BehaviourController.TryGetBehaviour(out var behaviourResult)) throw new Exception($"{nameof(IKeyboardInputs)} is missing on ${GameObject.Name}."); + inputs = behaviourResult; + inputs.RegisterOnPress(Up, OnUpPressed); inputs.RegisterOnRelease(Up, OnUpReleased); diff --git a/Game/Game1.cs b/Game/Game1.cs index ece01ab..93f2f0b 100644 --- a/Game/Game1.cs +++ b/Game/Game1.cs @@ -12,8 +12,8 @@ namespace Pong; public class Game1 : Game { - private GraphicsDeviceManager _graphics; - private SpriteBatch _spriteBatch; + private GraphicsDeviceManager _graphics = null!; + private SpriteBatch _spriteBatch = null!; private GameManager gameManager = null!; public Game1() @@ -23,6 +23,8 @@ public class Game1 : Game PreferredBackBufferWidth = 1024, PreferredBackBufferHeight = 576 }; + _spriteBatch = new SpriteBatch(GraphicsDevice); + Content.RootDirectory = "Content"; IsMouseVisible = true; } @@ -39,8 +41,6 @@ public class Game1 : Game protected override void LoadContent() { - _spriteBatch = new SpriteBatch(GraphicsDevice); - Sprite spriteBox = new Sprite() { Texture2D = Content.Load("Sprites/Pixel") }; Sprite spriteBall = new Sprite() { Texture2D = Content.Load("Sprites/Circle") };