diff --git a/Mine2d/assets/background.png b/Mine2d/assets/background.png index 5bb380a..96a1788 100644 Binary files a/Mine2d/assets/background.png and b/Mine2d/assets/background.png differ diff --git a/Mine2d/assets/blocks/dripstone-down.png b/Mine2d/assets/blocks/dripstone-down.png index fb03d14..2199435 100644 Binary files a/Mine2d/assets/blocks/dripstone-down.png and b/Mine2d/assets/blocks/dripstone-down.png differ diff --git a/Mine2d/assets/blocks/dripstone-up.png b/Mine2d/assets/blocks/dripstone-up.png index e6a1839..36666db 100644 Binary files a/Mine2d/assets/blocks/dripstone-up.png and b/Mine2d/assets/blocks/dripstone-up.png differ diff --git a/Mine2d/game/core/data/Chunk.cs b/Mine2d/game/core/data/Chunk.cs index f015b87..3a53c35 100644 --- a/Mine2d/game/core/data/Chunk.cs +++ b/Mine2d/game/core/data/Chunk.cs @@ -46,7 +46,7 @@ public class Chunk var posInChunk = this.GetPositionInChunk(new Vector2(x, y)); var tileX = (int)Math.Floor(posInChunk.X / Constants.TileSize); var tileY = (int)Math.Floor(posInChunk.Y / Constants.TileSize); - if(!this.HasTile(tileX, tileY)) return false; + if (!this.HasTile(tileX, tileY)) return false; return Context.Get().TileRegistry.GetTile(this.GetTile(tileX, tileY).Id).IsSolid(); } @@ -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) diff --git a/Mine2d/game/core/tiles/DecoTile.cs b/Mine2d/game/core/tiles/DecoTile.cs new file mode 100644 index 0000000..0009a45 --- /dev/null +++ b/Mine2d/game/core/tiles/DecoTile.cs @@ -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; + } +} \ No newline at end of file diff --git a/Mine2d/game/core/tiles/TileRegistry.cs b/Mine2d/game/core/tiles/TileRegistry.cs index 949b46b..e824eeb 100644 --- a/Mine2d/game/core/tiles/TileRegistry.cs +++ b/Mine2d/game/core/tiles/TileRegistry.cs @@ -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) diff --git a/Mine2d/game/core/world/ChunkGenerator.cs b/Mine2d/game/core/world/ChunkGenerator.cs index 637e1d4..aad5b7e 100644 --- a/Mine2d/game/core/world/ChunkGenerator.cs +++ b/Mine2d/game/core/world/ChunkGenerator.cs @@ -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); @@ -34,11 +34,39 @@ 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)); + if (n > 0.08) continue; 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; } diff --git a/Mine2d/game/state/FrontendGameState.cs b/Mine2d/game/state/FrontendGameState.cs index ae584ba..e7578d8 100644 --- a/Mine2d/game/state/FrontendGameState.cs +++ b/Mine2d/game/state/FrontendGameState.cs @@ -27,14 +27,14 @@ public class DebugState { public string ConsoleInput { get; set; } = ""; public List 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;