I opted to try to emulate the game Minesweeper. It compiles and runs fine but is not very robust for user input. Thus, items 2 and 3 together replace your NumberBesideMine method.After taking a course in C++, I have written my first program and I'm looking for some feedback both on coding style and maybe algorithmic improvements. BoardPeices // undo the mine1 cell increment Int bottom = Clamp(mine1.PositionY - 1, 0, maxY) įinally, let's iterate. Int top = Clamp(mine1.PositionY - 1, 0, maxY) ![]() Int right = Clamp(mine1.PositionX + 1, 0, maxX) Int left = Clamp(mine1.PositionX - 1, 0, maxX) Int maxY = BoardPeices.GetLength(1) - 1 // Should be 4 int maxX = BoardPeices.GetLength(0) - 1 // Should be 4 private static T Clamp(T x, T min, T max) NET that don't have the Math.Clamp method, let's create a simple method to clamp a value x into the range. It could be achieved via 2D loop (2 nested loops).įirst (optional), if you use an old version of. If (mine1.PositionX = 4 & mine1.PositionY = 4)īoardPeices++ Įlse if (mine1.PositionX = 0 & mine1.PositionY = 0)Įlse if (mine1.PositionX = 0 & mine1.PositionY = 4)Įlse if (mine1.PositionX = 4 & mine1.PositionY = 0)Īs far I understand you need to intersect your 5x5 board with a 3x3 square with a center in mine1. How would I make my class Board better? using System I didn't really understand how to make it so everything besides the zero opens up. ![]() I created a simple minesweeper game in c#, and wanted to know how to improve it.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |