Engine-Pong/Game/Behaviours/MovementBallBehaviour.cs

21 lines
621 B
C#
Raw Normal View History

2023-11-27 12:00:25 +03:00
using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Input;
using Syntriax.Engine.Core;
using Syntriax.Engine.Input;
namespace Pong.Behaviours;
public class MovementBallBehaviour(Vector2 StartDirection, float Speed) : BehaviourOverride
{
public Vector2 StartDirection { get; } = StartDirection;
public float Speed { get; set; } = Speed;
protected override void OnInitialize() => StartDirection.Normalize();
protected override void OnUpdate(GameTime time)
{
GameObject.Transform.Position += StartDirection * (time.ElapsedGameTime.Nanoseconds * .001f) * Speed;
}
}