diff --git a/Game/Behaviours/PongScoreboard.cs b/Game/Behaviours/PongScoreboard.cs index 16e7893..5322ba4 100644 --- a/Game/Behaviours/PongScoreboard.cs +++ b/Game/Behaviours/PongScoreboard.cs @@ -1,5 +1,9 @@ using System; + +using Microsoft.Xna.Framework.Input; + using Syntriax.Engine.Core; +using Syntriax.Engine.Input; namespace Pong.Behaviours; @@ -15,6 +19,18 @@ public class PongScoreboard(int WinScore) : BehaviourOverride public int WinScore { get; } = WinScore; + + protected override void OnFirstActiveFrame() + { + KeyboardInputsBehaviour? buttonInputs = null!; + + if (!BehaviourController.TryGetBehaviour(out buttonInputs)) + buttonInputs = BehaviourController.AddBehaviour(); + + buttonInputs.RegisterOnRelease(Keys.Space, (_, _1) => Reset()); + } + + public void ScoreToLeft() { ScoreLeft++; diff --git a/Game/Game1.cs b/Game/Game1.cs index 2e4b853..f26b6de 100644 --- a/Game/Game1.cs +++ b/Game/Game1.cs @@ -192,9 +192,6 @@ public class Game1 : Game if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape)) Exit(); - if (Keyboard.GetState().IsKeyDown(Keys.Space)) - pongScoreboard.Reset(); - gameManager.Update(gameTime.ToEngineTime()); while (physicsTimer + 0.01f < gameTime.TotalGameTime.TotalMilliseconds * .001f)//seconds) {