feat: add Player class wrapping Camera with chunk-coordinate accessor
This commit is contained in:
53
VoxelEngine.Tests/PlayerTests.cs
Normal file
53
VoxelEngine.Tests/PlayerTests.cs
Normal file
@@ -0,0 +1,53 @@
|
||||
using OpenTK.Mathematics;
|
||||
using VoxelEngine.Core;
|
||||
using VoxelEngine.Game;
|
||||
using Xunit;
|
||||
|
||||
namespace VoxelEngine.Tests;
|
||||
|
||||
public class PlayerTests
|
||||
{
|
||||
[Fact]
|
||||
public void ChunkPosition_Origin_IsZero()
|
||||
{
|
||||
var p = new Player(new Configuration(), new Vector3(0, 0, 0), aspectRatio: 1f);
|
||||
Assert.Equal(new Vector3i(0, 0, 0), p.ChunkPosition);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ChunkPosition_PositiveCoords_FloorsDown()
|
||||
{
|
||||
var p = new Player(new Configuration(), new Vector3(17.5f, 32f, 8f), aspectRatio: 1f);
|
||||
Assert.Equal(new Vector3i(1, 2, 0), p.ChunkPosition);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ChunkPosition_NegativeCoords_FloorsToNegativeInfinity()
|
||||
{
|
||||
var p = new Player(new Configuration(), new Vector3(-1f, -16f, -17f), aspectRatio: 1f);
|
||||
Assert.Equal(new Vector3i(-1, -1, -2), p.ChunkPosition);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ChunkPosition_PositiveExactBoundary_IsNextChunk()
|
||||
{
|
||||
var p = new Player(new Configuration(), new Vector3(16f, 0f, 0f), aspectRatio: 1f);
|
||||
Assert.Equal(new Vector3i(1, 0, 0), p.ChunkPosition);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Move_UpdatesPosition()
|
||||
{
|
||||
var p = new Player(new Configuration(), new Vector3(0, 0, 0), aspectRatio: 1f);
|
||||
p.Move(new Vector3(5, 0, 0));
|
||||
Assert.Equal(5f, p.Position.X);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Constructor_AppliesFovFromConfiguration()
|
||||
{
|
||||
var cfg = new Configuration { Fov = 75f };
|
||||
var p = new Player(cfg, new Vector3(0, 0, 0), aspectRatio: 1.5f);
|
||||
Assert.Equal(75f, p.Camera.Fov);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user