added block breaking
This commit is contained in:
16
Chunk.cs
16
Chunk.cs
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user