feat: Basic Ball Movement
This commit is contained in:
20
Game/Behaviours/MovementBallBehaviour.cs
Normal file
20
Game/Behaviours/MovementBallBehaviour.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
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;
|
||||
}
|
||||
}
|
@@ -6,7 +6,7 @@ using Syntriax.Engine.Input;
|
||||
|
||||
namespace Pong.Behaviours;
|
||||
|
||||
public class MovementBehaviour(Keys Up, Keys Down, float Speed) : BehaviourOverride
|
||||
public class MovementBoxBehaviour(Keys Up, Keys Down, float Speed) : BehaviourOverride
|
||||
{
|
||||
private Keys Up { get; } = Up;
|
||||
private Keys Down { get; } = Down;
|
Reference in New Issue
Block a user