/pygames

Primary LanguagePython

Read Me

Welcome to the ReadMe file for Creating Games Using PyGame

The source code for this book is structured the following way:

Intro Python source:

There are two files from the book for introducing both python and pygames.

The first is the intro_to_python.py source. This code goes along with the Intro to Python chapter. Most of the source is commented out. You can uncomment it easily in Visual Studio Code as you are learning about each python feature in the chapter. In Visual Studio Code you can uncomment a section of code by selecting the code you want to uncomment with the mouse and typing Ctrl-K-U. This will remove the # from each line in the section you highlighted.

To run the intro_to_python.py file, go to the directory containing the file and then run

python -m intro_to_python.py

The second intro file is intro_to_pygame.py. This file goes along with the chapter called Intro To PyGame. To run this file type:

python -m intro_to_pygame.py

Games

All of the game samples are in their own folders labelled as follows

  • tic-tac-toe
  • stones (the stone eater game)
  • space invasion

To run tic-tac-toe, cd into the stones directory and run

python -m stones.py

To run tic-tac-toe, cd into the tic-tac-to directory

cd tic-tac-toe

and run:

python -m tictactoe.py

or

python -m tictactoewithclasses.py (depending which chapter you are on)

To run the Stone Eater game go to the stones directory

cd ../stones

and run the stones.py file

python -m stones.py

To run the space invasion game go to the spaceinvasion directory

cd ../spaceinvasion

and run spaceinvasion.py

python -m spaceinvasion.py