Making a Map based game
In class we looked at the TicTacToe game.
This code can easily be extended to make boards with any grid size (but the boards must be square).
UPDATEIn the interests of saving time, here's the starting point for the Map program.. It was initially going to be a minesweeper game.
Map and Continent project: Grid (part I)
- Draw a grid sized GRIDSIZE x GRIDSIZE (some even number between 20 and 32)
- Make an array of the same size. Fill it with 1 (land) or 0 (empty) randomly.
Make sure that half of the array is each value.
- Go through each cell in the array and if there's a 1, colour that square green on the grid.
Sample screen shot showing random land, lakes, oceans
Map and Continent: Mouse (part II)
- When you right-click the mouse, toggle the colour/value of the square between land and empty This is already done in the code above!
Map and Continent: Lakes (part III)
- When you click on an empty space, it colours that square and all adjacent squares light blue (lake)
The process of doing this is called "recursion" which is something that you need to start learning about.
Map and Continent: Oceans (part IV)
- If a lake touches the edge of the board, it is an ocean. Colour it dark blue.
See the screen shot from part I.
You can do part V before part IV if you want.
Map and Continent: Continents (part V)
- Change how you make the random land squares so that they tend to clump together to make continents
Sample screen shot of continents
- More images:
Map and Continent: Load/Save (part VI)
- Get Save and Load working.
We'll do this as a class (or just not do it).