Racey
NOTE: You will need to have both Python and Pygame installed to use this tutorial.
ONE: Follow the Build Basic Game steps to create your first python game
TWO: Choose from the Add One Tasks to extend your game
This tutorial based on content from https://pythonprogramming.net/
pygame install error
If you have had issues with using PIP to install pygame
Re-install Python and make sure that
On the first installation window, check the box labeled “Add python.exe to PATH” (or “Add Python to environment variables”).
Or manually add python to your Path
WINDOWS: https://www.mygreatlearning.com/blog/add-python-to-path/
Racey – Basic Game Build
1: Racey – Initial Setup
Create a Project Folder Add a new folder where you save your school work and…
2. Racey – Display Images
Create a Project Folder Save the following image (racecar.png) into your project folder (you probably…
3. Racey – Movement
STEP Three – A x_change = 0 ########################################################## ## ## ## Replace this with Code…
4. Racey – Boundaries
STEP Four – A car_width = 73 car_width = 73 STEP Four – B gameExit…
5. Racey – Displaying Text
STEP Five – A import time import randomimport time import random STEP Five – B…
6. Racey – Drawing Objects
STEP Six – A def things(thingx, thingy, thingw, thingh, color): pygame.draw.rect(gameDisplay, color, [thingx, thingy, thingw,…
7. Racey – Crashing
STEP Seven #collision for thing if thing_starty > display_height: thing_starty = 0 – thing_height thing_startx…
8. Racey – Scoring
STEP Eight – A def things_dodged(count): font = pygame.font.SysFont(None, 25) text = font.render(“Dodged: “+str(count), True,…
Racey – Add-ons
1. Racey – Cheat Code
Task: Add a Cheat to stop crashing STEP ONE: ADD IN AN ADDITIONAL KEY EVENT…
2. Racey – Thing Image
Look at the code we have for adding the car image and drawing it on…
3. Racey – Change Game Play
Modify the game play so that you get points for hitting the thing rather than…
4. Racey – Creating a Class
STEP ONE: LOAD A DOG IMAGE You will need to find an image and save…
5. Racey – Adding Instances
Now you might want to add multiple instances of your class STEP ONE: Randomly placing…
6. Racey – Move class instance
STEP ONE: ADDING A MOVE FUNCTION TO OUR CLASS Inside our class declaration we need…
7. Racey – Using Vectors
In order to assign different movement directions to different instances of our class we need…
8. Racey – Direction Vectors
Now we want to add a vector for movement. STEP ONE: MODIFYING THE INIT FUNCTION…
9. Racey – Using Rect Collisions
Pygame has a Rect function we can use to determine if two objects collide. We need to…
10. Racey – Score from Collision
Each time the car collides with an instance of the array of obstacles we remove…