Adding Details and Instructions
Now that the city is created we’re almost ready to start programming the behavior of the Saucer and the controls to move Kodu. But there are just a couple more items to tend to — dropping some Coins in the city and shrinking down Kodu and Saucer so they can fit between the buildings and move easily on the streets.
First, the Coins. You already know how to add a Kodu or Saucer object, so all you need to do now is drop in three Coins. (You can modify the game later by adding more coins or reducing the number of coins found.)
Select the Object Tool and click on an empty bit of terrain. From the pie menu that appears, click on the pie slice shown in Figure 23. You can see the gold Coin object on it, but you must click on this pie slice to open up another pie slice that contains the Coin.
Figure 23 Time to add some Coins
Do this two more times and you’ll have three Coins sitting near the edge of the city as shown in Figure 24.
Figure 24 Three Coins ready to be hidden in the city
Zoom out and rotate your view until you’re looking straight down again on the city. Change to the Object Tool and left-click and hold a coin so you can drag and drop it somewhere on a street. Do this for the remaining coins — if you look carefully at Figure 25 you can see that I’ve placed three coins at three different intersections.
Figure 25 The Coins are placed between skyscrapers
Now it’s time to shrink down Kodu and Saucer a bit. Rotate and zoom in a bit on the Saucer as shown in Figure 26.
Figure 26 Time to shrink the Saucer
Click on the Object Tool icon and then right-click on the Saucer. A menu will appear like the one in Figure 27.
Figure 27 Right-click an object to view its menu
Click on the Change Size button and then drag the bar to the left until the Saucer shrinks in size. You can see this drag bar in Figure 28.
Figure 28 Use a Drag Bar to resize an object
While I’m working on Saucer, I want to also change Saucer’s distance from the ground. Right-click on the Saucer again and choose the Change Height option. Drag the Drag Bar to the left until Saucer is closer to the ground. Figure 29 shows that I’ve shrunk Saucer and lowered it a bit. I also moved Saucer onto a city street by dragging and dropping it.
Figure 29 Saucer is smaller and closer to the ground
Rotate your terrain and do the same thing with Kodu. Figure 30 shows that I’ve shrunk Kodu so it will easily be able to move down the streets and not get stuck (or blocked) by any skyscraper.
Figure 30 Kodu is also smaller, but he doesn't fly so no height change is needed
Two tasks remain: (1) Program Kodu so player can control movement and weapon firing, and (2) Program Saucer for random movement and firing on player. Let’s tackle Kodu’s movement first.
Zoom in a bit on Kodu and right-click on it. From the menu that appears, choose the Program menu. A screen will appear like the one in Figure 31.
Figure 31 An object's programming screen
When you first program an object, the programming screen is empty. Notice the WHEN and DO boxes (each with a + sign) are displayed to the right of a number (a 1 in this instance). Programming an object in Kodu Game Lab is mainly a matter of deciding what type of action to take when something happens:
WHEN [something happens] DO [an action]
In this case, I want Kodu to move when I press certain keys on the keyboard. Traditional computer games use the WASD configuration — the A key turns the player to the left, D turns the player to the right, W moves the player forward, and S moves the player backwards. The WHEN-DO programming might read like this:
WHEN (a WASD key is pressed) DO [move Kodu in the corresponding direction]
That should work here, so the first thing you’re going to want to do is click on the + in the WHEN box and click on the Keyboard pie slice shown in Figure 32.
Figure 32 Choose the Keyboard option
By selecting Keyboard, you’re specifying you wish Kodu to do something when a keyboard key (or keys) is pressed. You could program Kodu to use a Gamepad, a mouse, or even your finger (if you’re using a tablet with a touchscreen). But for now, choose Keyboard and then click the + to the right of the Keyboard icon shown in Figure 33.
Figure 33 The Keyboard has been added to the WHEN box
After clicking the + to the right of the Keyboard, a new pie menu appears like the one in Figure 34. Click on the WASD pie slice.
Figure 34 Choose WASD to control Kodu's movement
Look back at Figure 34 and you’ll notice there are many more options — you could have used the Arrows option to control Kodu with the Left/Right/Up/Down arrow keys... you could also use the Letters option to specify a single letter button on the keyboard. Fortunately Kodu Game Lab can handle monitoring the WASD keys for you so you won’t have to program each movement (left, right, forward, or back) individually!
Next we need to deal with what to do when the WASD keys are pressed. This is done in the DO box. Click the + sign to the right of the DO box and you’ll see a menu appear like the one in Figure 35.
Figure 35 Time to program the actions for the WASD keys
Remember how I told you you’ll only be using about 5% of the tools and features of Kodu Game Lab? Figure 35 contains even more options for what can occur when the WASD keys are pressed, but in this case our choice is really easy: choose the Move option! Once you’ve clicked on the Move option, Kodu’s programming screen should look like the one in Figure 36.
Figure 36 Kodu's movement programming is complete
Tap the ESC key (Escape) key on your keyboard to return to the game. It’s time to test out Kodu’s movement! Press the Play button (it’s the triangle to the right of the House icon on the toolbar) and take Kodu for a spin. Use the WASD keys to drive him around on the screen. Figure 37 shows me driving him down one of the safe city streets. Safe for now...
Figure 37 Taking Kodu for a drive
Now let’s focus on the Saucer. Rotate and zoom in on the saucer and then right-click on it. Choose the Program option (like you did for Kodu) and you’ll once again see a blank programming screen. Time to change that.
Because Saucer will be roaming on its own (with no human controlling it), there’s no need to program the WHEN box. If the WHEN box is left empty, it’s the same as saying ALWAYS- DO [something]. What do we want Saucer to do? Roam randomly.
So, to do this, click on the + sign to the right of the DO box and choose the Move option. Saucer’s programming screen will look like the one in Figure 38.
Figure 38 Saucer is programmed to just... move
If you press the Play button and watch, you’ll see that Saucer moves quite randomly around the city (even off and away from it at times), and at very high speeds. Let’s modify that a bit. Click on the + sign again to the right of the Move option and choose the Slowly option. Press Play and notice the speed difference. You can even click the + sign again and add another Slowly option if you like!
Next you’re going to program Saucer to fire on Kodu if it sees Kodu. To do this involves adding another WHEN-DO line of programming. So, right-click on Saucer, choose Program, and open up the programming screen again. You’ll notice that after you created some programming for the first line, a new line is automatically added (and numbered 2, of course). Click on the + sign next on the WHEN box and choose the See option. The See option will be added, but you still need to specify what you wish Saucer to be looking for... Kodu! So, click on the + sign to the right of the See option and choose… Kodu! Your second line of programming should look like the one in Figure 39.
Figure 39 Saucer is programmed to be on the lookout for Kodu
What does the Saucer need to do when it sees Kodu? Fire a missile, obviously. So, click on the + sign for the DO box and choose Shoot. But shoot what? Click the + sign to the right of the Shoot option and choose the Missile option. Now the second line of programming looks like the one in Figure 40.
Play the game and notice what happens – Saucer immediately fires a missile followed by a BUNCH of missiles. Is the game cheating? Not really. What’s happening is that the buildings haven’t really been programmed as real visual obstructions to Saucer. Saucer can see everywhere, so it fires missiles immediately. What’s needed is to specify Line-of-Sight firing. This means that Saucer will only fire when it can see Kodu directly... if something is blocking Saucer’s sight to Kodu, it won’t fire a missile. To do this, you’ll need to modify the firing program a bit.
Go back to the WHEN box and click the + sign to the right of the Kodu option and choose the Options pie slice shown in Figure 40.
Figure 40 Fine-tuning the programming requires the Options pie slice
After clicking on Options, you’ll see another pie menu like the one in Figure 41 – click on the LOS (Line of Sight) option and it’s added to the program.
Figure 41 Choose LOS option
Play the game again and you’ll notice this time that Saucer only fires when it can see Kodu directly. That problem is fixed, but there’s another one — the missile can fly over the buildings! If the player tries to run from a missile, the missile will fly up and over and around a building to hit the player. That’s not good. To change that, let’s modify the programming for the missile. Click on the + sign after the Missile option and you’ll see a pie menu like the one in Figure 42.
Figure 42 Modify the missile so it flies straight and level
From the new pie menu, choose the Level option. Figure 43 shows the newly modified Saucer program that contains the LOS and Level options that make the game a little more fair.
Figure 43 Saucer's new program
After testing the game, I’ve found a few more changes that should be made. First, a single missile from Saucer will destroy Kodu. I want to modify that so it takes four missile hits to destroy Kodu. To do this, I’m going to modify how much damage the missile can do, AND I’m going to modify Kodu’s health.
First, I right-click on Kodu — from the pop-up menu, choose Change Settings. A scrolling list of options appears like the one in Figure 44.
Figure 44 Each object can be fine-tuned with the Settings list
Use the mouse scroll wheel or the Up/Down arrow keys to move down the list until you reach the Max Hit Points option. Drag the bar to the right to give Kodu 100 health points as seen in Figure 45.
Figure 45 Increase Kodu's health points
Tap the ESC key and right-click on Saucer and choose Change Settings. A similar scrolling list will appear, but this time I want you to find the Missile Damage drag bar shown in Figure 46. Drag it to the left and set it to a value of 25. (It will take four missile hits to destroy Kodu – 25 damage/missile x 4 missiles = 100 health points.)
Figure 46 Decrease the damage value done by each missile
Tap the ESC key to leave the Settings list.
The game is almost done, but there are two small tweaks to make that will make the game more enjoyable for your player: (1) Change the POV (point of view) so the player sees everything from Kodu’s perspective... it will feel like you’re actually walking/gliding down the city streets, and (2) End the game if the player finds a coin.
To change the POV, open Kodu’s programming screen again and click the + sign to the right of the DO box on line number 2. Select the View option from the pie menu that appears and then click on the 1st Person option. Kodu’s new programming screen should look like the one in Figure 47.
Figure 47 The player will now see through Kodu's eyes
Test the game and go hunting for a coin. Figure 48 shows what a coin will look like on the streets from Kodu’s perspective.
Figure 48 1st Person View of the city streets
All that’s left is to add programming to end the game when a coin is picked up. Once again, open up Kodu’s programming screen and click on the + sign to the right of the WHEN box. Choose the Bump option. Next, click the + sign to the right of the Bump option and choose the Coin option from the Objects pie slice. You’re programming screen should look like the one in Figure 49 at this point.
Figure 49 Programming Kodu to test for bumping a coin
What happens when Kodu bumps a coin? The game should end! So, click the + sign to the right of the DO box and click on the Game pie slice shown in Figure 50.
Figure 50 This slice contains options for ending the game
A new pie menu appears. Click on the Win option. Kodu’s final programming screen should look like the one in Figure 51.
Figure 51 The game will end (player wins) if a Coin is bumped
Play the game! Find a coin and you should get a screen like the one seen in Figure 52.
Figure 52 Player Wins!
Congratulations! You’ve just programmed a simple one-player game with Kodu Game Lab... and hopefully in 60 minutes or less.
As you can see, Kodu Game Lab is easy to use — most everything is done with the mouse during the actual programming of a game: select, drag, move, scroll, etc. And it’s all visual and very fun to use.
What’s great about Kodu Game Lab is that it’s so easy to experiment with any game you create. You can design two-player games or up to six-player games. You can add scoreboards. You can have objects speak to you (on screen with text). You can program Power Ups. And so much more.
What could you do to upgrade Skyscraper Panic, for example? Well, here are some ideas:
- After Kodu collects two Coins, Kodu gets missiles to fire back.
- Program the Coins to wander around or even run from Kodu!
- Add another Saucer to make the game more difficult.
- Increase the size of the city.
- Place hazards (like water or pits) that will damage Kodu when touched.
- Add a countdown timer that ends the game — Saucer wins if no coins are collected.
- Add a Power Up that briefly turns Kodu invisible to the Saucer.
- Limit where Saucer may roam — provide a safe area to take a rest.
- Change from 1st Person View to Bird’s-eye (looking down from above).
- Increase the Saucer’s movement speed but decrease its missile speed.
As you can see, there’s a lot you can do with this simple game, but hopefully you’ve got some ideas for games of your own. You’ll be happy to know that games created in Kodu Game Lab can be shared with your friends... or the entire world. You can get feedback from your games from others and improve them or make changes based on suggestions.
The key is to have fun... and programming with Kodu Game Lab is fun! Good luck!