## With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

No credit card required

Creating the Game Map

In Chapter 12, you learned how to use lists to store lists of information. In this chapter, we’re going to use a list to store a map that shows where the bricks are. This is quite a bit more complex. The lists we’ve used so far are just like a single column of information. Each list item was just a number or a piece of text. A map is two-dimensional, so we’ll use a nested list, or a list in which each list item is also a list. To put it another way, we’re going to make a list of rows, and each list item will itself be a list containing the information for each column in that row.

It’s easier to understand if you look at an example, so this is how we create our map list:

`map=[`

`#-----0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9--`

` [0,0,0,0,1,1,0,0,0,0,0,0,0,0,1,1,0,0,0,0],`

` [0,0,0,1,1,1,1,0,0,0,0,0,0,1,1,1,1,0,0,0],`

` [0,0,0,0,1,1,1,1,0,0,0,0,1,1,1,1,0,0,0,0],`

` [0,0,0,0,0,1,1,1,1,0,0,1,1,1,1,0,0,0,0,0],`

` [0,0,0,0,0,0,1,1,0,0,0,0,1,1,0,0,0,0,0,0],`

` [0,0,0,0,0,0,0,0,0,2,2,0,0,0,0,0,0,0,0,0],`

` [0,0,0,0,0,0,2,2,2,2,2,2,2,2,0,0,0,0,0,0],`

` [0,0,0,0,0,2,2,2,2,2,2,2,2,2,2,0,0,0,0,0],`

` [0,0,0,0,0,2,2,2,2,2,2,2,2,2,2,0,0,0,0,0],`

` [0,0,0,0,2,2,2,2,2,2,2,2,2,2,2,2,0,0,0,0],`

` [0,0,0,0,2,2,2,2,2,2,2,2,2,2,2,2,0,0,0,0],`

` [0,0,0,0,0,2,2,2,2,2,2,2,2,2,2,0,0,0,0,0],`

` [0,0,0,0,0,2,2,2,2,2,2,2,2,2,2,0,0,0,0,0],`

` [0,0,0,0,0,0,2,2,2,2,2,2,2,2,0,0,0,0,0,0],`

` [0,0,0,0,0,0,0,0,0,2,2,0,0,0,0,0,0,0,0,0],`

` [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],`

` [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], ...`

## With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

No credit card required