Engine-Pong/Game/Behaviours/RotatableBehaviour.cs

30 lines
809 B
C#
Raw Normal View History

using Microsoft.Xna.Framework;
using Apos.Shapes;
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;
}
}