Game Development Reference
In-Depth Information
1 2 3 4 5
012345678901234567890123456789012345678901234567890123456789
0 ~~~`~``~~~``~~~~``~`~`~`~`~~`~~~`~~`~``````~~`~``~`~~```~`~` 0
1 `~`~````~~``~`~```~```~```~`~~~``~~`~~~``````~`~``~~``~~`~~` 1
2 ```~~~~`~`~~```~~~``~````~~`~`~~`~`~`~```~~`~``~~`~`~~~~~~`~ 2
3 ~~~~`~~~``~```~``~~`~`~~`~`~~``~````~`~````~```~`~`~`~`````~ 3
4 ~```~~~~~`~~````~~~~```~~~`~`~`~````~`~~`~`~~``~~`~``~`~``~~ 4
5 `~```~`~`~~`~~~```~~``~``````~~``~`~`~~~~`~~``~~~~~~`~```~~` 5
6 ``~~`~~`~``~`````~````~~``~`~~~~`~~```~~~``~`~`~~``~~~```~~~ 6
7 ``~``~~~~~~```~`~```~~~``~`~``~`~~~~~~```````~~~`~~`~~`~~`~~ 7
8 ~~`~`~~```~``~~``~~~``~~`~`~~`~`~```~```~~~```~~~~~~`~`~~~~` 8
9 ```~``~`~~~`~~```~``~``~~~```~````~```~`~~`~~~~~`~``~~~~~``` 9
10 `~~~~```~`~````~`~`~~``~`~~~~`~``~``~```~~```````~`~``~````` 10
11 ~~`~`~~`~``~`~~~````````````````~~`````~`~~``~`~~~~`~~~`~~`~ 11
12 ~~`~~~~```~~~`````~~``~`~`~~``````~`~~``~```````~~``~~~`~~`~ 12
13 `~``````~~``~`~~~```~~~~```~~`~`~~~`~```````~~`~```~``~`~~~~ 13
14 ~~~``~```~`````~~`~`~``~~`~``~`~~`~`~``~`~``~~``~`~``~```~~~ 14
012345678901234567890123456789012345678901234567890123456789
1 2 3 4 5
We will split up the drawing in the drawBoard() function into four steps. First, we
create a string variable of the line with 1, 2, 3, 4, and 5 spaced out with wide gaps. Second,
we use that string to display the X-axis coordinates along the top of the screen. Third, we
print each row of the ocean along with the Y-axis coordinates on both sides of the screen.
And fourth, we print out the X-axis again at the bottom. Having the coordinates on all sides
makes it easier for the player to move their finger along the spaces to see where exactly
they want to plan a sonar device.
Drawing the X-coordinates Along the Top
7. # Draw the board data structure.
8.
9. hline = ' ' # initial space for the numbers down
the left side of the board
10. for i in range(1, 6):
11. hline += (' ' * 9) + str(i)
Let's look again at the top part of the board, this time with plus signs instead of blank
spaces so we can count the spaces easier:
Figure 13-3: The spacing we use for printing the top of the game board.
Search WWH ::




Custom Search