A1 - Multi-Scene Games
In this unit, we're going to look at games that have multiple scenes. A scene could be a level, a title screen, or anything similar. For the first few assignments, we will be working from a game that I've started for you.
To get started, run update.bat.
You will probably also need to run, inside the Library\op_arcade_module subdirectory, setup.py to reinstall the op_arcade package.
Next, in Visual Studio code, open the following folder:
From within this folder, run the file title_screen.py to see what the code does.
There are several files in here that make this all work, and we will eventually get through them all in detail.
Task 1
Add to the scene:
- At least one more
FlyorBlueBird - Several more coins. Similarly to the ones that have already been placed, use a loop to place them in a line (or you could even use nested loops to place them in a grid)
Task 2
Add a coin counter to the dashboard. We did something like this back in Unit 2. Check back to that assignment for a reminder of how to do this.
You'll need to modify the following files:
-
sprites.py- give the player an additional attribute that keeps track of the number of coins it has selected. Also add some logic so that when the player collects a coin, this attribute is updated. -
base_level.py- create acoin_displayobject, modelled off of the existinghealth_displayobject currently in that file.
Task 3
In sprites.py, add a new enemy and give it some behaviour that differs from the fly and bluebird.
For example, you could make it wander around randomly or in a pattern.
The easiest way to get an image for your enemy would be to choose something here, but feel free to download your own image. I'm not going to go into how to create your own animated sprites just yet, but we'll do that soon!