How it works...

As before, we create a new Tkinter application that contains a Canvas widget, so that we can add all of the game objects. We ensure that we bind the right, left, up, down and Enter keys, which will be our controls in the game.

First, we place our background image (bg.gif) onto the Canvas widget. We calculate the number of images we can fit along the length and width to tile the whole canvas space, and locate them using suitable coordinates.

Next, we create the player image (by creating playImg, a list of Tkinter image objects for each direction the player can turn in) and place it on the canvas.

We now create the walls, the positions of which are defined by the wallPosH and wallPosV lists. These could be defined using the ...

Get Raspberry Pi 3 Cookbook for Python Programmers - Third Edition now with O’Reilly online learning.

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