Beginning a racing game
Getting started with Kodu - Lesson 4
Objectives
- Plan and design a 3D game environment
- Create and refine sequences of commands to make a character move
- Use logical reasoning to debug algorithms
Lesson Resources
Lesson 1 - Collecting games: eating apples
Lesson 2 - Collecting games: Building your world
Lesson 3 - Collecting games: Baddies, challenges and evaluations
Lesson 4 - Beginning a racing game
Lesson 5 - Racing games: adding conditions
Lesson 6 - Racing games: Evaluating the game
Introduction
The next three lessons will cover the second part of this unit, and the project of creating a racing game!
Start by asking the students what they already know about racing games.
- What sort of racing games have you played?
- What features do they have?
They may have played games like Mario Kart, Sonic all star racers, Forza Motorsport, Drive Club, Formula 1 games. Some of these are cartoon style action racers, some are more lifelike with real cars models and realistic tracks, performance and handling of the cars.
Mario Kart Deluxe 8 - image courtesy: https://www.flickr.com/photos/161227653@N02/43016211571/
Forza Horizon 4 - Image courtesy of: https://www.flickr.com/photos/152930510@N02/32088321677
Within most of these games there are different styles of race, common types are:
- Circuit races - complete a number of laps of a track, first round wins.
- Lap time trials - complete a number of laps of a track (usually on your own without other cars), fastest time wins.
- A to B races - Race against other vehicles to get from one point to another (not laps), first to the end wins.
- A to B time trials - Drive on your own to get from one point to another (not laps), fastest time wins.
The racers we create are going to be A to B races. They will let you race against an AI (artificially intelligent) opponent. We can also add obstacles and baddies to make the race more challenging, as well as power ups and special features.
Add your racer
For this type of game we're going to add a character at the beginning, but we won't do any coding at this point. The character is just there to give us an idea of scale as we create our track. Without a character on the land at the beginning it’s very easy to create a track that is totally out of proportion, either too narrow and short or much too wide and long (which will make the barometer move into red quickly!)
The cycle character works especially really well for racing games as it can can drive along on its wheel and all the special features we'll consider adding later work with the Cycle. Note, the Rover character drives well but cannot do all things the cycle can do.
Create the track
Once you’ve added a character it's best to start this project by building the world, unlike the collecting game where it was important that the students begin with the basic code of getting the game to work, and in the process, get to know Kodu.
Demonstrate creating an interesting track that will work well for this kind of racing game. Key teaching points are:
- Set the brush size with the left/right arrow keys to a sensible width for the track.
- The track should be one long path, it should not loop back on itself
- The round brush creates smoother corners and nicer edges to your track than the square brush.
- Moving the camera to be zoomed out and looking down from above makes drawing the track easier.
- Move the brush slowly when you paint so you don’t get gaps in the track.
Your track might initially look a bit like this:
Next add hills, but be sure to make them smooth as any character with wheels can get stuck on slopes that are too steep or ‘blocky’. The smooth/flatten tool will help with this:
Fill troughs with water, add trees, rocks and scenery to make your track exciting!
The fastest way to add lots of trees or other object is to add one, then hover over it and copy it by pressing Ctrl+C on your keyboard. Then move your mouse cursor to where you’d like to place the next one and paste it by pressing Ctrl+V.
Students may want to make sections of the track different colours, especially the start and end of the track. In the example above there is also a castle on the hill at the end of the track (the winner will be the first one to the castle). So adding some kind of building at the end is a good idea - there are a few to choose from, such as the castle, factory or hut.
Hit the road!
Once you are happy with the look of your track it is important that you thoroughly test it. To do this you can add some simple code to your character to make it move forwards with the arrow keys.
It’s also suggested that you speed up your character by going to it’s settings and increasing the forward speed and acceleration and the turning speed and acceleration. How far you should increase it will depend on your track, but somewhere between halfway and three quarters along the bars is a good place to start.
Lowering the ‘bounciness’ of the character can also make it’s handling better. You can also find this in the character settings if you continue to scroll down the list. This makes it less bouncy if you hit edges of the track and objects.
The children can test their track to look for problems. They should ask themselves:
- Is it smooth and easy to navigate?
- Is it an interesting track and fun to drive? - does it have a mix of corners, straights, hills and flat sections?
- Are there are any places that the characters get stuck?
- Is it too short or too long?
- Is the characters speed and turning settings correct?
- Do they need to adjust the bounciness?
Ensure that everyone saves their work at the end of the lesson.
Plenary
Ask them to swap seats with a friend and test each other's track out. At the end, review the progress of the students' games so far.
- Does it work well?
- Is your track smooth and drivable?
- Did you have to change anything?
- Is it too easy or too hard?
- How can we adjust the difficulty of the game by altering the track or the character?
- What could we add next?