refactor: Pong Reset Key Press Moved Into PongScoreboard

This commit is contained in:
2024-01-30 12:28:34 +03:00
parent a9c7b8b660
commit 677fec7acc
2 changed files with 16 additions and 3 deletions

View File

@@ -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<KeyboardInputsBehaviour>();
buttonInputs.RegisterOnRelease(Keys.Space, (_, _1) => Reset());
}
public void ScoreToLeft()
{
ScoreLeft++;