player added
This commit is contained in:
30
Camera.cs
30
Camera.cs
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user