player added

This commit is contained in:
maxwes08
2025-09-30 10:58:12 +02:00
parent 38dccf0a84
commit 11f76ca429
11 changed files with 259 additions and 48 deletions

View File

@@ -21,39 +21,15 @@ namespace Voxel
{
get
{
float yawOffset = Yaw - 90f;
Vector3 front;
front.X = MathF.Cos(MathHelper.DegreesToRadians(Yaw)) * MathF.Cos(MathHelper.DegreesToRadians(Pitch));
front.X = MathF.Cos(MathHelper.DegreesToRadians(yawOffset)) * MathF.Cos(MathHelper.DegreesToRadians(Pitch));
front.Y = MathF.Sin(MathHelper.DegreesToRadians(Pitch));
front.Z = MathF.Sin(MathHelper.DegreesToRadians(Yaw)) * MathF.Cos(MathHelper.DegreesToRadians(Pitch));
front.Z = MathF.Sin(MathHelper.DegreesToRadians(yawOffset)) * MathF.Cos(MathHelper.DegreesToRadians(Pitch));
return front.Normalized();
}
}
public static void Update(float time)
{
float moveSpeed = Speed * time;
if (Input.GetKey(OpenTK.Windowing.GraphicsLibraryFramework.Keys.LeftShift))
{
moveSpeed = ShiftSpeed * time;
}
if (Input.GetKey(OpenTK.Windowing.GraphicsLibraryFramework.Keys.W))
{
Position += Front * moveSpeed;
}
if (Input.GetKey(OpenTK.Windowing.GraphicsLibraryFramework.Keys.S))
{
Position += Front * -moveSpeed;
}
if (Input.GetKey(OpenTK.Windowing.GraphicsLibraryFramework.Keys.A))
{
Position += Vector3.Cross(Front, Vector3.UnitY).Normalized() * -moveSpeed;
}
if (Input.GetKey(OpenTK.Windowing.GraphicsLibraryFramework.Keys.D))
{
Position += Vector3.Cross(Front, Vector3.UnitY).Normalized() * moveSpeed;
}
}
public static void UpdateMouse(Vector2 delta)
{
float sensitivity = 0.1f;