(no title)
DenisDolya | 29 days ago
bombMap is filled with rand()%2, which means ~50% of tiles are mines and the `mines` variable is basically unused. That’s not Minesweeper, that’s Russian roulette. Better: clear bombMap first, then place exactly `mines` mines randomly without duplicates.
tileMap is int, but you print it with putchar(). Zero prints nothing, so your board is mostly invisible. Either store ASCII chars ('#', '.', '', '1'..'8') or map numbers to chars when printing.
Utils.hpp include guard is broken: you have #ifndef but no #define. So the guard does nothing. Add #define or use #pragma once.
Utils::catchReturn() always returns 0, so errors are swallowed. You print “sending further” and then… don’t send anything further. Just return renum.
In editDiff(), custom values are not validated. Width/height should be 1..32, mines < wh. Otherwise you can overflow your arrays.
Also this line looks wrong: std::cout << Game::boardWidth; boardWidth is not static, and printing it there does nothing useful.
Main advice: first make a minimal playable version: - select difficulty - initBoard() - displayBoard() - simple input loop - win/lose check
No UI polish, no docs, just make it playable first. Then iterate.
Just focus on making one complete working path instead of half-implemented features.
dawidg81|28 days ago
Today in the code, (I hope that) I've fixed some of the bugs you've mentioned, for example tile map. It's still type of an integer but in displayBoard() I've made small number-to-character translation so for example if tileMap is 0 it puts a '#' (unrevealed tile).
I've also completely removed Utils class and files of it, I thought that I don't really need them. Recently I was just learning about classes in C++ and got a little crazy about them, okay maybe not crazy but interested. Utils class may come back if the code will be ever more complicated.
In editDiff() I've replaced functions from Utils class with traditional if statements checking if user doesn't want to put too big board width and height and amount of mines.
There is no game loop yet but I'm going to add it in near future in the main file. I've also made small changes in the initBoard() so the bomb map is cleared first with zeros. Though I'm not sure about the loops randomly filling the map with mines. I've added additional third loop in the two loops iterating.
After making a basic game loop i start making game logic.
dawidg81|28 days ago
Even though the project feels for me lighter after CMake removal I feel like I just lost something. That could be the old fear of deleting whole directory with actually useful for me files.
Also when I looked in the repository statistics I didn't expect so much site visits. I'm pretty new in all this Hacker News website. I'm glad it's effective. Pretty cool website.
Ok This is propably all for now, see you