- Modify your
showMap() function developed in
Sokoban (1)
to take an additional parameter "scale".
- Define a variable "scale" in the main program with initial value 1.
Users can
press the '+' and '-' key to increase/decrease the size of the map.
For example, when scale = 1, the original map is
.
When scale=3, each cell is displayed as a 3x3 block.
.
- You may test your functions with the following main program:
n = 0
scale = 1
myMap = readMap(n)
while True:
showMap(myMap, scale)
c = stdscr.getkey()
if c == 'q':
break
elif c == '+':
scale = scale + 1
elif c == '-':
scale = scale - 1
- If you want to clear the screen when you scale down the map,
you may invoke the
erase()
function.
- The default window size of PuTTY is MAX_ROW=25 and MAX_COLUMN=80,
but this can be changed by the user. Therefore, be sure to check the value of
scale to prevent it from being too large or too small (becoming 0).
You may obtain the number of rows and columns of the current window
by the statement
max_y, max_x = stdscr.getmaxyx()