26 lines
760 B
C#
26 lines
760 B
C#
using Syntriax.Engine.Core;
|
|
|
|
namespace Pong.Behaviours;
|
|
|
|
public class RotatableBehaviour : BehaviourOverride
|
|
{
|
|
private KeyboardInputsBehaviour? inputs = null;
|
|
|
|
protected override void OnFirstActiveFrame()
|
|
{
|
|
if (!BehaviourController.TryGetBehaviour(out inputs))
|
|
inputs = BehaviourController.AddBehaviour<KeyboardInputsBehaviour>();
|
|
}
|
|
|
|
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;
|
|
}
|
|
}
|