![]() ![]() ![]() Nice Idea about storing the 9s positions.īut about the 'edge' what if the user can choose the size of the array, it will be difficult figure which position will be the other edge(eg.Continuing from yesterdays post about Minesweeper as an introduction to game programming today we are going to start by creating Minesweeper in Java, a traditional starting language. (eg.: array means you shouldn't increment array, array and array) (If a mine gets planted on an incremented field) But it saves you the trouble of having to scan the whole array for 9's of which you just had the position.Īn alternative would be to temporarily store their positions when they get placed, and use that for easy finding.Īnd as the user above has stated if you land on an ''edge'' you need to keep out some of the increment instructions.īut I'm sure you can figure out which instructions those are. This will give you the possibility of doing useless increments. Instead of scanning the whole array for 9's I would immediately increment adjacent fields as soon as your random generator chooses a spot. so remove all nearby squares specified above containing "m-1". M=0 means that the scan is currently in the TOP row, and so it doesnt have a nearby square above it. Then some parts of those nearby squares i specified above will have to be removed. If u found a 9 at the 1st row, last row, leftmost column, or rightmost column The brackets must be filled with the appropriate indexes which u can find above. If those nearby squares are NOT a 9, then increment them by simply: Suppose, you used m and n as counters and your array was named a:Ī -> let's say in your scan, you found this square to contain a 9 and be aware that you have to detect if you are currently scanning the TOP-most, BOTTOM-most, LEFT-most or RIGHT-most parts of the array. ![]() if u find a 9, increment all nearby squares by 1 (but do not increment those containing a 9). ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |