feat: Basic Ball Movement

This commit is contained in:
2023-11-27 12:00:25 +03:00
parent 49566e6981
commit e134192187
3 changed files with 24 additions and 3 deletions

View 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;
}
}

View File

@@ -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;