21 lines
621 B
C#
21 lines
621 B
C#
|
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;
|
||
|
}
|
||
|
}
|