feat: Mouse Movement
This commit is contained in:
parent
e252d8fbb2
commit
427ab5ed54
|
@ -0,0 +1,13 @@
|
||||||
|
using System;
|
||||||
|
using Microsoft.Xna.Framework.Input;
|
||||||
|
using Syntriax.Engine.Core;
|
||||||
|
|
||||||
|
namespace Pong.Behaviours;
|
||||||
|
|
||||||
|
public class MovementMouseBehaviour : BehaviourOverride
|
||||||
|
{
|
||||||
|
protected override void OnUpdate()
|
||||||
|
{
|
||||||
|
GameObject.Transform.Position = Mouse.GetState().Position.ToVector2D().ApplyDisplayScale();
|
||||||
|
}
|
||||||
|
}
|
|
@ -13,6 +13,8 @@ public static class EngineConverter
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public static Vector2D ToVector2D(this Vector2 vector) => new(vector.X, vector.Y);
|
public static Vector2D ToVector2D(this Vector2 vector) => new(vector.X, vector.Y);
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
public static Vector2D ToVector2D(this Point point) => new(point.X, point.Y);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public static Vector2 ToVector2(this Vector2D vector) => new(vector.X, vector.Y);
|
public static Vector2 ToVector2(this Vector2D vector) => new(vector.X, vector.Y);
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public static Vector2 ToDisplayVector2(this Vector2D vector) => vector.Scale(screenScale).ToVector2();
|
public static Vector2 ToDisplayVector2(this Vector2D vector) => vector.Scale(screenScale).ToVector2();
|
||||||
|
|
|
@ -77,10 +77,9 @@ public class Game1 : Game
|
||||||
|
|
||||||
IGameObject gameObjectCircle2 = gameManager.InstantiateGameObject<GameObject>();
|
IGameObject gameObjectCircle2 = gameManager.InstantiateGameObject<GameObject>();
|
||||||
gameObjectCircle2.Name = "Circle2";
|
gameObjectCircle2.Name = "Circle2";
|
||||||
gameObjectCircle2.Transform.Position = new Vector2D(0f, 50f);
|
gameObjectCircle2.Transform.Position = new Vector2D(5f, 50f);
|
||||||
gameObjectCircle2.Transform.Scale = new Vector2D(25f, 25f);
|
gameObjectCircle2.Transform.Scale = new Vector2D(25f, 25f);
|
||||||
gameObjectCircle2.BehaviourController.AddBehaviour<KeyboardInputsBehaviour>();
|
gameObjectCircle2.BehaviourController.AddBehaviour<MovementMouseBehaviour>();
|
||||||
gameObjectCircle2.BehaviourController.AddBehaviour<MovementBoxBehaviour>(Keys.Up, Keys.Down, 268f, -268f, 400f);
|
|
||||||
gameObjectCircle2.BehaviourController.AddBehaviour<CircleBehaviour>(new Circle(Vector2D.Zero, 1f));
|
gameObjectCircle2.BehaviourController.AddBehaviour<CircleBehaviour>(new Circle(Vector2D.Zero, 1f));
|
||||||
engine.AddRigidBody(gameObjectCircle2.BehaviourController.AddBehaviour<RigidBody2D>());
|
engine.AddRigidBody(gameObjectCircle2.BehaviourController.AddBehaviour<RigidBody2D>());
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue