chore: Compiler Warnings Fixed

This commit is contained in:
Syntriax 2023-11-27 17:41:21 +03:00
parent 5512696a04
commit 8ec918ca04
2 changed files with 7 additions and 5 deletions

View File

@ -34,9 +34,11 @@ public class MovementBoxBehaviour(Keys Up, Keys Down, float High, float Low, flo
protected override void OnInitialize() protected override void OnInitialize()
{ {
if (!BehaviourController.TryGetBehaviour(out inputs)) if (!BehaviourController.TryGetBehaviour<IKeyboardInputs>(out var behaviourResult))
throw new Exception($"{nameof(IKeyboardInputs)} is missing on ${GameObject.Name}."); throw new Exception($"{nameof(IKeyboardInputs)} is missing on ${GameObject.Name}.");
inputs = behaviourResult;
inputs.RegisterOnPress(Up, OnUpPressed); inputs.RegisterOnPress(Up, OnUpPressed);
inputs.RegisterOnRelease(Up, OnUpReleased); inputs.RegisterOnRelease(Up, OnUpReleased);

View File

@ -12,8 +12,8 @@ namespace Pong;
public class Game1 : Game public class Game1 : Game
{ {
private GraphicsDeviceManager _graphics; private GraphicsDeviceManager _graphics = null!;
private SpriteBatch _spriteBatch; private SpriteBatch _spriteBatch = null!;
private GameManager gameManager = null!; private GameManager gameManager = null!;
public Game1() public Game1()
@ -23,6 +23,8 @@ public class Game1 : Game
PreferredBackBufferWidth = 1024, PreferredBackBufferWidth = 1024,
PreferredBackBufferHeight = 576 PreferredBackBufferHeight = 576
}; };
_spriteBatch = new SpriteBatch(GraphicsDevice);
Content.RootDirectory = "Content"; Content.RootDirectory = "Content";
IsMouseVisible = true; IsMouseVisible = true;
} }
@ -39,8 +41,6 @@ public class Game1 : Game
protected override void LoadContent() protected override void LoadContent()
{ {
_spriteBatch = new SpriteBatch(GraphicsDevice);
Sprite spriteBox = new Sprite() { Texture2D = Content.Load<Texture2D>("Sprites/Pixel") }; Sprite spriteBox = new Sprite() { Texture2D = Content.Load<Texture2D>("Sprites/Pixel") };
Sprite spriteBall = new Sprite() { Texture2D = Content.Load<Texture2D>("Sprites/Circle") }; Sprite spriteBall = new Sprite() { Texture2D = Content.Load<Texture2D>("Sprites/Circle") };