chunbk face culling

This commit is contained in:
maxwes08
2025-09-22 10:56:55 +02:00
parent 81ef6d8a29
commit 9a61dfd74c
5 changed files with 118 additions and 4 deletions

View File

@@ -15,6 +15,8 @@ namespace Voxel
private World _world;
public double lastClick = 0;
public readonly float mouseCooldown = 0.2f;
private int _blockIndex = 0;
private Blocks _selectedBlock = Blocks.Dirt;
public Player(World world, Vector3 startPos)
{
@@ -30,7 +32,7 @@ namespace Voxel
y += normal.Y;
z += normal.Z;
_world.SetBlock(x, y, z, Blocks.OakPlanks);
_world.SetBlock(x, y, z, _selectedBlock);
}
public void BreakBlock()
@@ -70,5 +72,22 @@ namespace Voxel
BreakBlock();
}
}
public void SwitchBlock(bool inverted)
{
var keys = BlockDefinitions.Blocks.Keys.ToList();
if (inverted)
if (_blockIndex == 0)
_blockIndex = keys.Count -1;
else
_blockIndex -= 1;
else
_blockIndex += 1;
_blockIndex = _blockIndex % keys.Count;
_selectedBlock = keys[_blockIndex];
Console.WriteLine(_selectedBlock);
}
}
}