Display the forest data structure on the screen.
(forest)
| 88 | |
| 89 | |
| 90 | def displayForest(forest): |
| 91 | """Display the forest data structure on the screen.""" |
| 92 | bext.goto(0, 0) |
| 93 | for y in range(forest['height']): |
| 94 | for x in range(forest['width']): |
| 95 | if forest[(x, y)] == TREE: |
| 96 | bext.fg('green') |
| 97 | print(TREE, end='') |
| 98 | elif forest[(x, y)] == FIRE: |
| 99 | bext.fg('red') |
| 100 | print(FIRE, end='') |
| 101 | elif forest[(x, y)] == EMPTY: |
| 102 | print(EMPTY, end='') |
| 103 | print() |
| 104 | bext.fg('reset') # Use the default font color. |
| 105 | print('Grow chance: {}% '.format(GROW_CHANCE * 100), end='') |
| 106 | print('Lightning chance: {}% '.format(FIRE_CHANCE * 100), end='') |
| 107 | print('Press Ctrl-C to quit.') |
| 108 | |
| 109 | |
| 110 | # If this program was run (instead of imported), run the game: |