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; the player 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, and perhaps even additional tools or puzzles to solve. With a few adjustments to the graphics, the character could be exploring a dungeon, a spaceship, or hopping through the clouds, collecting rainbows!