added dripstone gen

This commit is contained in:
MasterGordon 2022-12-30 17:18:00 +01:00
parent 6bc5748bc9
commit 7f94a2eb20
8 changed files with 58 additions and 7 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 338 B

After

Width:  |  Height:  |  Size: 297 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 224 B

After

Width:  |  Height:  |  Size: 239 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 205 B

After

Width:  |  Height:  |  Size: 217 B

View File

@ -78,7 +78,7 @@ public class Chunk
public bool HasTile(int x, int y)
{
return x >= 0 && x < this.Tiles.Length && y >= 0 && y < this.Tiles.Length && this.Tiles[x, y].Id != 0;
return x >= 0 && x < Constants.ChunkSize && y >= 0 && y < Constants.ChunkSize && this.Tiles[x, y].Id != 0;
}
public bool HasTile(Vector2 pos)

View File

@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Mine2d.game.core.data;
namespace Mine2d.game.core.tiles;
public class DecoTile : Tile
{
public DecoTile(string name, string textureName, int hardness, ItemId drop) : base(name, textureName, hardness, drop)
{
}
public override bool IsSolid()
{
return false;
}
}

View File

@ -21,6 +21,8 @@ public enum Tiles
TungstenOre = 15,
UraniumOre = 16,
DiamondOre = 17,
DripstoneUp = 18,
DripstoneDown = 19,
}
public class TileRegistry
@ -46,6 +48,8 @@ public class TileRegistry
this.Tiles.Add(15, new OreTile("tungsten-ore", new[] { "stone", "tungsten-ore" }, 15, ItemId.RawTungsten));
this.Tiles.Add(16, new OreTile("uranium-ore", new[] { "stone", "uranium-ore" }, 15, ItemId.RawUranium));
this.Tiles.Add(17, new OreTile("diamond-ore", new[] { "stone", "diamond-ore" }, 10, ItemId.Diamond));
this.Tiles.Add(18, new DecoTile("dripstone-up", "dripstone-up", 5, ItemId.Air));
this.Tiles.Add(19, new DecoTile("dripstone-down", "dripstone-down", 5, ItemId.Air));
}
public Tile GetTile(int id)

View File

@ -6,7 +6,7 @@ namespace Mine2d.game.core.world;
public class ChunkGenerator
{
private static WorldGenerator wg = new WorldGenerator();
private static readonly WorldGenerator WG = new();
public static Chunk CreateFilledChunk(int x, int y, STile fill)
{
var chunk = new Chunk(x, y);
@ -35,10 +35,38 @@ public class ChunkGenerator
var n = (Noise.coherentNoise(i + (x * 32), j + (y * 32), 0, 1, 25, 0.5f, 0.9f));
// Console.WriteLine(i * (x * 32) + " "+ j * (y * 32));
if (n > 0.08) continue;
fill.Id = (int)wg.GetRandomOreAt(j + (y * 32));
chunk.SetTile(i, j, fill);
}
}
for (var i = 0; i < Constants.ChunkSize; i++)
{
for (var j = 0; j < Constants.ChunkSize; j++)
{
if (!chunk.HasTile(i, j))
{
if (chunk.HasTile(i, j + 1) && chunk.GetTile(i, j + 1).Id == (int)Tiles.Stone)
{
if (new Random().NextInt64(0, 100) < 5)
{
chunk.SetTile(i, j, STile.From((int)Tiles.DripstoneUp));
}
}
if (chunk.HasTile(i, j - 1) && chunk.GetTile(i, j - 1).Id == (int)Tiles.Stone)
{
if (new Random().NextInt64(0, 100) < 25)
{
chunk.SetTile(i, j, STile.From((int)Tiles.DripstoneDown));
}
}
}
else
{
fill.Id = (int)WG.GetRandomOreAt(j + (y * 32));
chunk.SetTile(i, j, fill);
}
}
}
return chunk;
}

View File

@ -27,14 +27,14 @@ public class DebugState {
public string ConsoleInput { get; set; } = "";
public List<string> ConsoleHistory { get; set; } = new();
public int ConsoleHistoryIndex { get; set; } = 0;
public bool NoClip { get; set; } = true;
public bool NoClip { get; set; } = false;
public bool NoFog { get; set; } = false;
public string Overlay { get; set; } = "none";
}
public class Settings
{
public int GameScale { get; set; } = 1;
public int GameScale { get; set; } = 5;
public int UiScale { get; set; } = 4;
public bool ShowCollision { get; set; } = true;
public bool Fullscreen { get; set; } = false;