Teach Your Kids To Code: A Parent-friendly Guide to Python Programming

(vip2019) #1
Timers and Animation: What Would Disney Do? 177

To get started, install the pygame module by downloading the
installer from the Downloads page at http://www.pygame.org/.
For Windows, you’ll probably want to download pygame-1.9.1
.win32-py3.1.msi, but see Appendix B for help if you have any
trouble. For Mac and Linux, the installation is more involved; see
Appendix B or go to http://www.nostarch.com/teachkids/ for
step-by-step instructions.
You can check that Pygame installed with no errors by enter-
ing the following into the Python shell:





import pygame





If you get a regular >>> prompt in response, you know that
Python was able to find the pygame module without error and the
Pygame library is ready to use.


Drawing a Dot with Pygame


Once you have Pygame installed, you can run a short sample pro-
gram to draw a dot on the screen, like the one in Figure 8-2.


Figure 8-2: The ShowDot.py program at work

Free download pdf