added block breaking

This commit is contained in:
2025-09-03 00:37:42 +02:00
parent 00713db79e
commit 94ebc4ace4
6 changed files with 171 additions and 36 deletions

View File

@@ -2,8 +2,8 @@
{
public class Chunk
{
public readonly int Size = 16;
public readonly int Height = 256;
public static int Size = 16;
public static int Height = 256;
public readonly int PositionX;
public readonly int PositionY;
@@ -45,9 +45,12 @@
private void Initialize()
{
Random rng = new Random();
for (int i = 0; i < Size * Size * 16; i++)
_blocks[i] = (Blocks)rng.Next(5);
for (int i = 0; i < Size * Size; i++)
_blocks[i] = Blocks.Bedrock;
for (int i = Size * Size * 1; i < Size * Size * 15; i++)
_blocks[i] = Blocks.Stone;
for (int i = Size * Size * 15; i < Size * Size * 16; i++)
_blocks[i] = Blocks.Grass;
}
// todo
@@ -62,6 +65,9 @@
private int GetBlockIndex(int x, int y, int z)
{
if (x < 0 || x > 15 || y < 0 || y > 255 || z < 0 || z > 15)
return 0;
return x + z * Size + y * Size * Size;
}