Kodu: Understanding Pages
By Daniel D'Agostino, 2010-04-08
In Kodu, programmed logic (e.g. shoot when space button is pressed) can reside in one of several pages. Using a normal conditional, you can dynamically switch between pages, changing the way that objects respond to events.
The technical preview of Kodu Game Lab comes with several lessons, one of which is called "Technique: Changing Behavior". This lesson demonstrates how to use pages to respond to input differently, before and after a particular event took place.
In this particular lesson, you are on a motorbike and must jump to the other side of a chasm to reach a coin that will let you win the game. In order to jump, you must bump into a heart. Bumping into the heart will change the behaviour of the space button from shooting to jumping. Internally, this means changing the page.
To see this, go into edit mode and select Add and Program Objects. Right click on the player model and select Program.
You are now seeing the programmed logic for the player. When the gamepad's 'A' button is pressed, for example, the player is set to shoot a missile. Also, note how there is more logic that will switch to the second page when the player bumps into the heart.
The current page being used (1 being the first one) is shown at the top of the screen, and you can easily see the other pages by pressing Left or Right on your keyboard, or using the mouse.
In the second page you can see how instead of shooting a missile, the 'A' button on the gamepad is set to make the player jump.
Now you can try out this functionality. Leave edit mode (go into play mode). Pressing Space currently shoots a missile. Take the heart, then drive over to the edge and hold down Space on your keyboard to jump over the lava to the other side.
Now, drive over to the coin and take it.
Congratulations! You won!
The usefulness of pages when compared to conditionals in regular programming languages is debatable. If I just want to change one trigger, why do I have to duplicate a whole page and then make a small change in it? At this point I know too little about Kodu to know whether there is a better way of doing it. However, Kodu is targeted at young students; thus the advantage of such an approach are clearly to make programming events easier for children, and its clear drawback is not so bad considering that children will make very small-scale games.