CHAPTER 17

image

Array-Backed Grids

Games like minesweeper, tic-tac-toe, and many types of adventure games keep data for the game in a grid of numbers. For example, a tic-tac-toe board:

image

…can use a grid of numbers to represent the empty spots, the O’s, and the X’s like this:

image

This grid of numbers can also be called a two-dimensional array or a matrix. (Finally, we get to learn about The Matrix.) The values of the numbers in the grid represent what should ...

Get Program Arcade Games: With Python and Pygame, Fourth Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.