use relative mouse extension
parent
c97df29e28
commit
96b0990418
2
FNA
2
FNA
|
@ -1 +1 @@
|
|||
Subproject commit c665d2e08c25fb63e58e987b7c1af75af22aa010
|
||||
Subproject commit d926c536dc34186d64464154c72e8ba2cc187ed8
|
2
Kav
2
Kav
|
@ -1 +1 @@
|
|||
Subproject commit 55b1555df2ded543e623c8b5eb60d3a3fff9e32c
|
||||
Subproject commit 2d1a50e1c439e0d511de82eab6cd2481b1c011f8
|
|
@ -13,26 +13,10 @@ namespace KavTest.Engines
|
|||
)]
|
||||
public class InputEngine : Engine
|
||||
{
|
||||
private int centerX;
|
||||
private int centerY;
|
||||
|
||||
public InputEngine(int centerX, int centerY)
|
||||
{
|
||||
this.centerX = centerX;
|
||||
this.centerY = centerY;
|
||||
Mouse.SetPosition(centerX, centerY);
|
||||
System.Console.WriteLine("initialize mouse position");
|
||||
System.Console.WriteLine(Mouse.GetState().X);
|
||||
System.Console.WriteLine(Mouse.GetState().Y);
|
||||
}
|
||||
|
||||
public override void Update(double dt)
|
||||
{
|
||||
var keyboardState = Keyboard.GetState();
|
||||
var mouseState = Mouse.GetState();
|
||||
System.Console.WriteLine("mouse position");
|
||||
System.Console.WriteLine(mouseState.X);
|
||||
System.Console.WriteLine(mouseState.Y);
|
||||
|
||||
if (keyboardState.IsKeyDown(Keys.W))
|
||||
{
|
||||
|
@ -54,13 +38,10 @@ namespace KavTest.Engines
|
|||
SendMessage(new MoveCameraMessage(new Vector3(5, 0, 0)));
|
||||
}
|
||||
|
||||
var mouseMovement = new Vector2(centerX - mouseState.X, centerY - mouseState.Y);
|
||||
Mouse.SetPosition(centerX, centerY);
|
||||
|
||||
if (SomeComponent<CameraComponent>())
|
||||
{
|
||||
var cameraEntity = ReadEntity<CameraComponent>();
|
||||
SendMessage(new RotateCameraMessage(cameraEntity, mouseMovement.X, mouseMovement.Y));
|
||||
SendMessage(new RotateCameraMessage(cameraEntity, -mouseState.X, -mouseState.Y));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,6 +27,8 @@ namespace KavTest
|
|||
|
||||
Window.AllowUserResizing = true;
|
||||
IsMouseVisible = true;
|
||||
|
||||
Microsoft.Xna.Framework.Input.Mouse.IsRelativeMouseModeEXT = true;
|
||||
}
|
||||
|
||||
protected override void LoadContent()
|
||||
|
@ -48,7 +50,7 @@ namespace KavTest
|
|||
Smuggler.Importer.ImportGLB(GraphicsDevice, File.OpenRead("Content/rustysphere.glb"))
|
||||
);
|
||||
|
||||
WorldBuilder.AddEngine(new InputEngine(GraphicsDevice.Viewport.Width / 2, GraphicsDevice.Viewport.Height / 2));
|
||||
WorldBuilder.AddEngine(new InputEngine());
|
||||
WorldBuilder.AddEngine(new AngularVelocityEngine());
|
||||
WorldBuilder.AddEngine(new MotionEngine());
|
||||
WorldBuilder.AddEngine(new CameraEngine());
|
||||
|
|
Loading…
Reference in New Issue