refactor: Pong Reset Key Press Moved Into PongScoreboard
This commit is contained in:
parent
a9c7b8b660
commit
677fec7acc
|
@ -1,5 +1,9 @@
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
|
using Microsoft.Xna.Framework.Input;
|
||||||
|
|
||||||
using Syntriax.Engine.Core;
|
using Syntriax.Engine.Core;
|
||||||
|
using Syntriax.Engine.Input;
|
||||||
|
|
||||||
namespace Pong.Behaviours;
|
namespace Pong.Behaviours;
|
||||||
|
|
||||||
|
@ -15,6 +19,18 @@ public class PongScoreboard(int WinScore) : BehaviourOverride
|
||||||
|
|
||||||
public int WinScore { get; } = WinScore;
|
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()
|
public void ScoreToLeft()
|
||||||
{
|
{
|
||||||
ScoreLeft++;
|
ScoreLeft++;
|
||||||
|
|
|
@ -192,9 +192,6 @@ public class Game1 : Game
|
||||||
if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
|
if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
|
||||||
Exit();
|
Exit();
|
||||||
|
|
||||||
if (Keyboard.GetState().IsKeyDown(Keys.Space))
|
|
||||||
pongScoreboard.Reset();
|
|
||||||
|
|
||||||
gameManager.Update(gameTime.ToEngineTime());
|
gameManager.Update(gameTime.ToEngineTime());
|
||||||
while (physicsTimer + 0.01f < gameTime.TotalGameTime.TotalMilliseconds * .001f)//seconds)
|
while (physicsTimer + 0.01f < gameTime.TotalGameTime.TotalMilliseconds * .001f)//seconds)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue