

We'll work on implementing the "how" part first. We need to make sure that if the map at each square is MAP_MINE, then the player has USER_FLAGGED if it's less than 10 (that is, either empty or a numbered square) then it needs to be USER_REVEALED. Well, we know what the underlying map looks like, and what the player's map-status looks like. Well, a player could (theoretically) win on any click, whether they reveal a square or not, so clearly we'll have to check after every click, before continuing the game. When do we need to detect whether a player has won or lost? First, we need to answer some important questions about how and when: This means we really only need to check for a player winning the game. We've already got code that will detect whenever a player explodes (this is in our main game loop), and it outputs "Boom, you're done!", then exits the game. The conditions for when a player wins or loses are fairly simple in Minesweeper: the player loses if they ever uncover a mine, and win if they reveal the whole map correctly without exploding. Find the previous parts here: Part 1, Part 2 and Part 3 complete all of these first.

This is part 4 of the Basic Game Programming tutorial.

Posted: Fri 7:20 pm Post subject: Basic Game Programming: Minesweeper, Part 4 Basic Game Programming: Minesweeper, Part 4 Wiki Blog Search Turing Chat Room Members
