2024-01-24 19:25:31 +03:00
|
|
|
using Syntriax.Engine.Core;
|
|
|
|
|
|
|
|
namespace Pong.Behaviours;
|
|
|
|
|
|
|
|
public class RotatableBehaviour : BehaviourOverride
|
|
|
|
{
|
|
|
|
private KeyboardInputsBehaviour? inputs = null;
|
|
|
|
|
|
|
|
protected override void OnFirstActiveFrame()
|
|
|
|
{
|
2024-01-27 14:47:29 +03:00
|
|
|
if (!BehaviourController.TryGetBehaviour(out inputs))
|
|
|
|
inputs = BehaviourController.AddBehaviour<KeyboardInputsBehaviour>();
|
2024-01-24 19:25:31 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
protected override void OnUpdate()
|
|
|
|
{
|
|
|
|
if (inputs is null)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (inputs.IsPressed(Microsoft.Xna.Framework.Input.Keys.NumPad4))
|
|
|
|
Transform.Rotation += Time.Elapsed.Nanoseconds * 0.0025f;
|
|
|
|
if (inputs.IsPressed(Microsoft.Xna.Framework.Input.Keys.NumPad6))
|
|
|
|
Transform.Rotation -= Time.Elapsed.Nanoseconds * 0.0025f;
|
|
|
|
}
|
|
|
|
}
|