The plan is to set up our game to have a demo race going on the start screen, and create a new race when we click a menu button. That means we'll need to be able to dynamically construct and destroy races, so we should make a Race
class for that. To further expand our menu use, we'll create a confirmation dialog menu so the player can let the game know when he's ready for the race to start. Roll up those sleeves; it's time to get busy again.
Open a blank document in NotePad++ and save it as
RaceClass_01.py
.As always, when creating a new class, we'll start with the imports. Add this code to our blank file:
from TrackClass_01 import Track from CycleClass_01 import Cycle
To get us rolling, we'll need the class definition and the
__init__
method. Here's the code for it:class Race: def __init__(self, inputManager): self.inputManager = inputManager self.cycles = [] self.track = None
That's a nice easy start. Next, we'll create a method that will start a...