refactor: Pong Reset Key Press Moved Into PongScoreboard
This commit is contained in:
@@ -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++;
|
||||
|
Reference in New Issue
Block a user