Sample Chapter

FREE Sample – Chapter 4 – Creating Games and Graphics

Packt Publishing have made available Chapter 4 of the book available FREE to download:

http://www.packtpub.com/raspberry-pi-cookbook-for-python-programmers/book

On the “Sample Chapters” tab, simply click on “download sample chapters in PDF format” link to download and view it.

 

Chapter contents

This chapter explains how to create a drawing application and graphical games using the Tkinter Canvas.

Using IDLE3 to debug your programs

Debugging using Idle

Drawing lines using a mouse on a Tkinter Canvas

Drawing on the Tkinter canvas

Creating a bat and ball game

Bat and Ball game

Creating an overhead scrolling game

Overhead scrolling game

Supporting files

The final example “Creating an overhead scrolling game” uses several images as sprites, which you will need in order to run the program.

To download the image files used in the sample chapter directly on your Raspberry Pi use the following command:

wget https://github.com/PiHw/Book/raw/master/Chapter-04/ch4images.zip
unzip ch4images.zip

Alternatively, you can download the files directly here.

https://github.com/PiHw/Book/raw/master/Chapter-04/ch4images.zip

 

Just ensure that when you run your scroller.py script, the following files are in the same directory.

bg.gif, gold.gif, mark.gif, playerD.gif, playerL.gif, playerR.gif, playerU.gif, wallH.gif, wallV.gif

 

You can also download the full code files for the book by selecting the “Support” tab and selecting “Download Files“.  You will need to register your email address and you should receive a direct link to the file.

 

Any questions or comments, then feel free to let me know.

Enjoy!

Comments

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.