Creating an overhead scrolling game
By using objects and images in our programs, we can create many types of 2D graphical games.
In this recipe, we will create a treasure hunt game where the player is trying to find buried treasure (by pressing Enter to dig for it). Each time the treasure has not been found, the player is given a clue to how far away the treasure is; they can then use the cursor keys to move around and search until they find it.
Although this is a basic concept for a game, it could easily be extended to include multiple layouts, traps, and enemies to avoid, perhaps even additional tools or puzzles to solve. With a few adjustments to the graphics, the character could be exploring a dungeon or spaceship or hopping through the clouds collecting rainbows!
Getting ready
The following example uses a number of images; these are available as part of the book's resources. You will need to place the nine images in the same directory...