From 7f94a2eb20c7070507c305fef6ef5d6356d1a067 Mon Sep 17 00:00:00 2001 From: MasterGordon Date: Fri, 30 Dec 2022 17:18:00 +0100 Subject: [PATCH] added dripstone gen --- Mine2d/assets/background.png | Bin 338 -> 297 bytes Mine2d/assets/blocks/dripstone-down.png | Bin 224 -> 239 bytes Mine2d/assets/blocks/dripstone-up.png | Bin 205 -> 217 bytes Mine2d/game/core/data/Chunk.cs | 4 +-- Mine2d/game/core/tiles/DecoTile.cs | 19 +++++++++++++ Mine2d/game/core/tiles/TileRegistry.cs | 4 +++ Mine2d/game/core/world/ChunkGenerator.cs | 34 +++++++++++++++++++++-- Mine2d/game/state/FrontendGameState.cs | 4 +-- 8 files changed, 58 insertions(+), 7 deletions(-) create mode 100644 Mine2d/game/core/tiles/DecoTile.cs diff --git a/Mine2d/assets/background.png b/Mine2d/assets/background.png index 5bb380a1ea9c556f895e0aede4a3d53f1bc6151e..96a17883e4a73b512ad76c7c5c0762074602df35 100644 GIT binary patch delta 257 zcmV+c0sj8d0;vL!Fn<8!NklIH-e)9Cy8j7PZJzB**~)yXlw#x(Zf> delta 299 zcmV+`0o4Af0@4DIFn<9INkl}Ps zU?Efl)1pV@?kJN(%vWvoeP1^K12s??X=^v`BKUbkky9kdF@FknEo}j)MX_8VA5jFp zN~>@Cx@S_J8j7OecDPE&Ib8a>IplT^snmy`+d(wAAGSN{4!8Q#Ik1{Rw<*oQmwnx2 zxH_=aw%ilU%0a%>w!||NQmrAF4tf%U3~;e^^YkXK+Lrka4rmagLavh+FLu<3R6deD x9P!!At~TvGR3ykFx&MTzo>-lUFH^jz_YH5Amr~>?ex3jT002ovPDHLkV1gqNjEw*Q diff --git a/Mine2d/assets/blocks/dripstone-down.png b/Mine2d/assets/blocks/dripstone-down.png index fb03d148e9b89c6bf6ad95b91bd7b0adb4dd5c44..2199435083576b02838d8c3a2bb4af716bd5e6a2 100644 GIT binary patch delta 198 zcmV;%06G8Q0q+5jF@LE^L_t(Ijir$>7K9)SL=zjV>F_F?fs;y?JFOkHRBjbs2oayV z)4&7f&j6TGx>n~v>#P;5b*+Vn@T|2n0>EIFXIOjAxadVTYUo{?4)8gS0i?xe_MEW+ z_!{2($Mh|PZof4kB4p6&TuZX9B!R;lFhnPnQrevBn*b^69Y3V`79hWt$1MaiWZFQt z(CJfv)#9fHy2Wb%r(5+O0Yqe)UMa?S{SBGv3r4PG7AVW~>;M1&07*qoM6N<$g7_y~ AH2?qr delta 183 zcmV;o07(Du0pJ0UF@Ks#L_t(Ijopwj5`!QRMISa;)8SP(11F8$-YIs}QkiNUL?ol> z@~fR4_Wd^)fEeR8TFZM`n7pSKee;@U126!Hh*@*SIS0U+^L|jy0F(EJ-JpYr7zL>f zz-a9Wq`L#41g$xrno>&ptoltrnX;*Md002ovPDHLkV1m`%QX~KX diff --git a/Mine2d/assets/blocks/dripstone-up.png b/Mine2d/assets/blocks/dripstone-up.png index e6a18392eb70770675af64d68e5145b43c75eec5..36666dbedd6d42f5161cdc23652a82ba39f3268c 100644 GIT binary patch delta 176 zcmV;h08jtT0oehNF@KXuL_t(IjkS?M4uBvG1h>Wn&U^>I(1-ai_zq_|;i(3zpwZ9^ zB+HiR78qUL`_j{=zaKm{aL#op#u6}dvBrFF003LgU44FPV2wF)ScnJ!)({SzT1I9* z1(#AnjPdgRc7)peIRkBMt@DDU(RJxjP6VQ0wGa4r7-QnBW_c?z9H6zHQhY}sB2h6v9{>PH2-5-UD5;q99X28YfZf`vhI)-6 zQXS5F59eIB_Oe3R{P+fK= 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;