Getting Started with Kodu Game Lab MAS/INFO111 Macquarie University – S2 2010 (Rev for PC) ............................................................................................................................... ...............................2 KODU FOR INFO/MAS 111 ................................ LOAD A WORLD ................................................................ ................................................................................................ ...............................................3 THE MAIN SCREEN................................................................ ................................................................................................ ................................................... 3 THE LOAD SCREEN ................................................................ ................................................................................................ ................................................... 3 SORTING THE WORLD LIST ................................ ................................................................................................................................ .......................................... 4 USE TAGS TO FILTER THE WORLD LIST................................ ............................................................................................................................ ............................ 4 NAVIGATING WITHIN A WORLD ................................................................................................ ................................ ......................................................5 STANDARD PC NAVIGATION CONTROLS ................................ ................................................................................................ ....................................................... 5 ADD OBJECTS TO THE WORLD .......................................................................................................................... ................................ ..........................5 THE TOOL PALETTE................................................................ ................................................................................................ ................................................... 5 ADD AN APPLE TO THE WORLD ................................................................................................................................ ................................ .................................... 6 ADD A CHARACTER TO THE WORLD ................................ .............................................................................................................................. .............................. 7 GETTING HELP ON INDIVIDUAL AL OBJECTS ................................................................................................ ..........................................8 MOVING AND REORIENTING NG CHARACTERS ................................................................................................ ......................................9 CREATE A VERY BASIC PROGRAM ................................................................................................ ................................ ..................................................10 ACTIVATE THE OBJECT TOOL AND CREATE A KODU ................................................................................................ ....................................... 10 OPEN THE PROGRAM EDITOR ................................................................................................................................ ................................ ................................... 10 THE SIMPLEST POSSIBLE PROGRAM: “JUST MOVE” ................................................................................................ ........................................ 11 DECIDING WHEN TO DO SOMETHING ................................ ................................................................................................ ............................................12 CHANGE “MOVE ALWAYS” TO “MOVE WHEN YOU SEE SO SOMETHING” ................................................................ ................................................. 12 “MOVE FORWARD WHEN YOU U SEE SOMETHING GREE GREEN” ................................................................................................ ................................. 13 MORE EXAMPLES ................................................................ ................................................................................................ ................................................... 13 GETTING HELP WHILE PROGRAMMING ROGRAMMING................................................................................................ ..........................................14 LANDSCAPING: MOVING GROUND UP OR DOWN.......................................................................................... .......................... 15 THE UP/DOWN TOOL ................................ ................................................................................................................................ ............................................ 15 CREATING NEW TERRAIN ................................ ............................................................................................................................... ............................... 16 THE ADD/REMOVE GROUND TOOL ................................ ............................................................................................................................. ............................. 16 CHOOSING TERRAIN TYPE................................ ................................................................................................................................ ........................................ 17 HOW TO MAKE ROUGH OR CURVY GROUND ................................................................................................ .................................18 ACTIVATE ROUGH OR CURVY TOOL ........................................................................................................................... ................................ ........................... 18 MAKE ROUGH OR CURVY GROUND ........................................................................................................................... ................................ ........................... 18 FOR FURTHER EXPLORATION ................................ ................................................................................................................................ .................................... 18 HOW TO MAKE FLAT AREAS...........................................................................................................................19 PICK THE FLATTEN TOOL .......................................................................................................................................... 19 MAKE FLAT AREAS ................................................................................................................................................. 19 ADDING WATER TO YOUR WORLD.................................................................................................................20 MAKE LAKES AND RIVERS ........................................................................................................................................ 20 BUILDING YOUR FIRST GAME IN KODU ..........................................................................................................21 GETTING STARTED ................................................................................................................................................. 21 BASIC MECHANICS OF SPACE INVADERS ...................................................................................................................... 21 CREATING ENEMIES ................................................................................................................................................ 23 OTHER FEATURES ................................................................................................................................................... 27 RESULTS .............................................................................................................................................................. 28 ASSIGNMENT NOTES .............................................................................................................................................. 28 KODU FOR INFO/MAS 111 Kodu is a videogame building environment. This very simple interface hides a huge amount of complex code, allowing us to focus on concepts of design and mechanics rather than syntax and debugging. That said, because of how much this program ‘does for you’ it isn’t as flexible as something like XNA, Unity or UnrealEditor that some of you may be familiar with. The first concept that Kodu assists us with is generating a 3D world. All the levels you will create for this course will begin as a 3D world simply by loading a blank world in the program. The next step is to add some terrain, whether it is an island or a pinball table—the word ‘terrain’ is used to describe the surface on which your game occurs. The objects you can add into your world are assets built into Kodu, so no you cannot import a model made in another editor and animate it here. You can always make a 2D game by fixing the camera to one side, and only allow the character(s) to move in 2 dimensions. The core of Kodu is the programming. Don’t be alarmed by this word, this is programming unlike anything you’ve seen, and probably will see again. Kodu relies on a rule-based behaviours system that is accessed via the same graphical interface as the rest of the environment. Fundamental behaviours are stored in individual tiles, using plain English, that you can chain together based on a ‘When… Do…” clause structure. There is no typing, and you’ll be hard-pressed to actually cause the program to crash (it might not do what you want, and it might go into a loop, but I haven’t ever made it crash.) So work your way through this booklet, keeping in mind that there may be more here than you can get through in one week. Feel free to experiment as well, this environment is designed to be a rapid prototyping model, so you can try things very quickly and see if they work. This manual was originally written for use on an XBox 360, not a PC with keyboard and mouse controls. So, occasionally there may be references to pressing a button on the controller that obviously doesn’t make sense when using a computer. Most of the controls are fairly intuitive, though there will be a few that aren’t ‘Windows standard.’ You should be able to figure out most of the controls yourself after reading through this manual, but if you still have trouble, speak to your practical instructor. Page 2 Getting Started with Kodu LOAD A WORLD THE MAIN SCREEN The Main screen provides four options: - Resume: open whatever level I last edited Load World: load a level from the hard drive Community: download levels from the Internet Options: Self-explanatory Help Quit Kodu We’re going to load a level from the local hard drive. Use the mouse, click load world. THE LOAD SCREEN World list Left/right arrows on keyboard or screen to scroll Current Game Details for Current Game The load screen shows eight games at a time. Details for each game are below the current game tile. You can show all the available worlds, or selected categories by using the large buttons near the top of the screen. PC Note: you can scroll through this menu either by using the left or right arrow keys, or clicking the green triangles on either side of the screen. Most screens in Kodu follow this convention of keyboard option and onscreen buttons. To launch the game, click the world once, then click Play on the pop-out menu. SORTING THE WORLD LIST You can sort worlds by date, creator or title. This can make it easier to find a world created by your friend or created on a certain day. Press the button to open the sort menu. Use the left stick to select different menu items and press to sort. To close the sort menu without sorting, press the button. PC Note: You will find the icon on the screen which you can click with the mouse to activate the same functions for sorting. This is another fairly standard control convention for the PC version. USE TAGS TO FILTER THE WORLD LIST Sometimes the list of worlds is long and you wan want to focus on a shorter list. Enter the tag menu. Each world may have several tags. Tags indicate, among other things, the type of game (racing, shooter, puzzle, etc.) To show only worlds having a given tag, press the X button to open the tag menu. Select a particular tag using the left stick, and press A to choose that tag. The list of worlds will now show only worlds that have that tag. PC Note: Click on the icon then click the category you want. Hit esc to show the games in that category NAVIGATING WITHIN A WORLD Let’s look at a very basic world so that we can learn how to move around and activate different modes. 1. 2. Open the load screen. Use the large category buttons to show only the Lessons worlds. 3. Open any world. You open the world by left clicking on it and selecting Play. When you open a level, it is in “play mode.” How it looks and how you move around will depend on the game. However, the following is pretty standard across all games: STANDARD PC NAVIGATION CONTROLS The cursor in the PC version is simply your normal Windows mouse cursor, not the white circle. - Zoom the Camera with the mouse scroll wheel. Change the camera angle by Right-Click and Drag. (although note you often don’t have full 360 on the camera – it may be limited) When Editing you can move around using the move camera command. In the move camera command you can zoom and change the camera angle as above, plus move the camera by left click and drag or use the WASD keys as in most 3D games. When using any of the other editing commands you can temporarily access the move camera command by holding down the space bar and then using any of the above camera operations. ADD OBJECTS TO THE WORLD THE TOOL PALETTE When you first launch a world, you are in Play Mode. When you want to edit the world, you need to first press ESC on the keyboard to switch to edit mode (also in the edit mode is the way back to the main menu). Open the world we used on the previous lesson: “Empty Stadium v01.” The world will open in play mode. Not that there is anything to do. Press ESC to enter Edit mode. Page 5 Getting Started with Kodu Tool Palette Selected Tool The tool palette at the bottom of the screen lets you choose a new tool. Simply click which tool you would like to use. The icon for tool you have selected will remain larger than the other tools in the palette. With the object tool active, you can move it around the world with the mouse. Select the Object tool, and notice how you can now ‘highlight’ objects in your world with the mouse cursor (well, you could if there were any there, so let’s add one). ADD AN APPLE TO THE WORLD With the object tool still active, left click somewhere in your game world. (Careful where you left click – that’s where the object will appear). The object radial menu will appear .Navigate this radial menu with the mouse. Note that a section with a dark pointed outer edge has more objects nested inside. Select the apple in the upper-right area of the menu by left clicking it to add an apple to the scene. Hit escape to close the radial menu If you place your cursor on the apple, the apple will be surrounded by a yellow glow. If you move your cursor away it will stop glowing. Some of the items in the Add Object Menu - such as the tree - will open smaller menus. ADD A CHARACTER TO THE WORLD Let’s add another object: - Move the cursor to a clear place in the world Left-click to open the Add Object menu Select the icon with the robots on it, as shown in the image to the right Clicking on this icon will open another menu (below, right.) This menu allows you to pick a specific character. NOTE: this is an example of a group menu. Group menus are used to organize the menu items so they are easier to navigate. You can identify a group menu because it has a point on it (above right) - Page 7 Select the Cycle character (highlighted at right) Left-click to insert the Cycle character into your world. Getting Started with Kodu GETTING HELP ON INDIVIDUAL VIDUAL OBJECTS Kodu provides interactive help for all the characters and objects. If you’re not sure what a character does does, or you want to see examples of a how you can use it, you can open the Help to read about the character and pick from a library of examples featuring that character. Whenever the Add Menu is open (below,) you can press Y on the keyboard to get help on the currently selected character. PC Note:: sometimes pressing the the corresponding letter (A, B, X, Y) on the keyboard will activate the XBox-controller controller equivalent. - Choose the character tool: Move the cursor to a place where you’d like to put a character - to open the Add Object menu (right) Press Navigate within the Add d Object Menu to find a character or object you’d like help for With that menu item active (don’t insert the character yet,) - press to open the help for that character MOVING AND REORIENTING CHARACTERS It’s common to create a character in one position and then realize that he would work better somewhere else. It’s also common to want to change which direction a character is facing. For both of these, it is useful to understand the different selection states that a character may be in: unselected, selected, and active. Moving characters is easy. - - Select the Object tool. If you don’t have a character in the scene, add one now. Move the cursor under the character that you want to move. The character should change from its unselected color (above right) to its active color yellow (middle right.) Left click and drag to pick up the character. It should change to pink - the selected color (below right) When a character is selected (pink) it “sticks” to the cursor. To rotate the character, right-click the character and choose Rotate from the menu. (There are lots of other options in the Right-click menu worth checking out.) Try moving the character around and reorienting it. . NOTE: if you have a lower-end graphics card, you will not see the glow effect on the character - but the cursor will still change color. Page 9 Getting Started with Kodu CREATE A VERY BASIC PROGRAM Return to the main menu and don’t save any changes. Now re-open Empty Stadium v01. You may use any other level for this lesson, but it will be easiest if the level you use doesn’t have any other characters in it. ACTIVATE THE OBJECT TOOL AND CREATE A KODU Press ESC to activate edit mode. Choose the Object tool from the palette. Now use the character add menu to add a Kodu to the scene. If you do not remember how to do this, please see the “Add ” section above. Keep the object tool active for the next steps. The object tool serves to edit programs as well as adding and removing objects. OPEN THE PROGRAM EDITOR To enter the program editor, right click on your Kodu robot. Click “Program” from the menu that appears. Here we see the program editor showing an empty program or, more precisely, a program consisting of one rule, which does nothing. Page 10 Getting Started with Kodu Pencil Cursor When Do Clause Clause (empty) Rule (empty) I mentioned that this program contains one rule. A rule tells the bot what to do and when to do it. The first part of a rule is the When Clause Clause.. It says when something is going to happen; the condition that will make the bot react. You can say things like ‘when I see something red’ or ‘when I bump into a tree’ or even ‘when 2 seconds have passed.’ Clause. It specifies what the actor should do when the ‘when part’ The second part of the rule is the Do Clause activates or ‘fires’. Bots can do all kinds of things, such as shoot, move, or eat. Different bots have different capabilities. The plus sign in the e rule lets you add more elements to the rule. We’ll talk more about that in a later section. THE SIMPLEST POSSIBLEE PROGRAM PROGRAM: “JUST MOVE” On the PC, the pencil cursor still appears to show you which rule you are currently editing, don’t worry about it too much. To edit a rule simply click the + next to the clause you wish to edit and you should see the Verb Menu (below right.) This menu shows different things this bot can do. Choose the move verb, and insert it into your program by clicking. Your program should now look like the picture on the bottom right. The verb menu lets you specify what the bot is going to do when this rule activates. Since we haven’t said when the rule should activate, it will be active all the time. In effect, what our program says is “always move.” Since we didn’t say which direction on or how to move, the bot will pick a direction. To run your program, press ESC on the keyboard twice (ESC often substitutes for the ‘Back’ convention that indicates on the XBox); this will close the programming UI, return to the tool menu, and then return to play mode. You should see your Kodu move in a straight line. DECIDING WHEN TO DO SOMETHING This lesson builds on the previous one. If you haven’t done it, please do it now. Activate the Object tool from the palette. Left click the gameworld to bring up the Character Add radial menu. Now use the Character Add dd menu to add a Kodu to the scene. If you don’tt remember how to do this, please see Add objects to the world. CHANGE “MOVE ALWAYS” TO “MOVE WHEN YOU SE SEE SOMETHING” Your scene should have one Kodu,, and his program should look like this. (Reminder: to see a character’s ch program, use the Object tool, right click on the character, and select Program. This program says “move no matter what.” We want to change it to say “when you see anything, move.” - Click the When clause in the rule to bring up the conditional statements. This shows you things that the bot can react to: he can react to things he sees, hears, or touches, controller input and so on. - Click see from the sensor menu to insert it in the menu. Your our program should look like this: Go ahead and try your program now. Press (ESC) to close the program editor, and press the start button (ESC again or the green Play arrow in the palette) to run the program. If you run this program in an empty world, Kodu will not move,, because he cannot see anything anything. If there are no objects in the world, use the Add menu to add an apple, tree, or anything else. Note that the ground and sky don’t count as objects. The empty stadium isn’t quite empty, so depending where your Kodu starts he may see something. There’s a tree on the far sode – see ifyou can delete it. When you do, your kodu shouodn’t move. “MOVE FORWARD WHEN YOU SEE SOMETHING GREEN” We’d like to change our program so that Kodu only moves when he sees something green. To do this, we will add to the When part of the rule. Open the program editor and put the pencil just after “See” tile. (see right) Click the + that follows “See” in the rule. Since you already have a see sensor in your program, opening the menu after this sensor gives you options for modifying the see operation. You don’t usually have to think about this; as you build a program, the menus will change to show the right options automatically. Let’s make our Kodu respond only to green objects: - Select the Colors menu from the modifier radial menu Select Green and add it into your program. Your program should now look like the below. It means “when you see anything green, move.” MORE EXAMPLES If you see a green Kodu, move. If you see a green Kodu, move away from it. The rule assumes that you move away from the thing you saw. Other modifiers include a ‘target’ aspect, ie. causing damage to itself or the thing it bumps into. Try surrounding your poor initial Kodu with green Kodus and see what happens. Note that Kodu’s vision is not 360o and he doesn’t move forever with the program you’ve given him. Page 13 Getting Started with Kodu GETTING HELP WHILE PROGRAMMING ROGRAMMING The program editor provides help for all the programming tiles. Whenever you are looking at a tile in a tile selector menu, you can press (Y on the keyboard) to get help on that specific tile. The help system will also show you help for the other tiles in n your program. You can also find related examples related to your program that you can easily insert into your program. - - Select a character and press the button to open the program editor (right) Enter the program shown (or any program) With a selectorr menu open and a tile selected (below right)) press the button for help on the selected tile The help for the selected tile will be displayed Note that the other tiles in your current row (see and Kodu in the below picture) will also appear at the top of the help screen. You can see help for those tiles by moving the left stick left and right. Examples related to your program are shown below. Move the stick up and down to select an example and press to insert the code into your program You can scroll through ough the various examples using the mouse scroll wheel. LANDSCAPING: MOVING GROUND UP OR DOWN Making hills and valleys is fun, easy, and allows you to set up interesting game mechanics. The shape of the ground affects character behavior: hills block vision, and some characters can’t climb steep hills. THE UP/DOWN TOOL From the Tool menu select the Up/Down tool. You will see a flashing area on your terrain. It’s purple in the picture at right but the color depends on the terrain. This is your brush; it shows which part of the ground the tool will affect. Most of the tools that affect terrain work like this. You can change the size of the brush by pressing the Right and Left arrow keys. (Notice the control tool tips on the left side of the screen.) You can change the brush shape by clicking on the blue images near the tool icon in the tool list. Position your brush in an empty area. Left click briefly and release it. You should see the area beneath the brush rise to form a small plateau (below right). You can lower terrain by right clicking. You can also move the brush while you are raising or lowering the ground. Try holding the right or left click while moving the mouse cursor - with practice you can paint mountain ranges and hills. Brushes come in many shapes. With one of the terrain tools selected, click the blue shapes in the top right of the icon to bring up the brush menu. Some of the brushes have different shapes and some of them work very differently. Play around with different brushes to see how they work. Page 15 Getting Started with Kodu CREATING NEW TERRAIN Kodu includes several stock worlds for you to use, but sometimes you need a custom shape to make the game you want. Using the Ground Brush tool, you can make worlds of many different sizes and shapes. The shape of the world is very important to game design and can make simple game programs much more interesting. Clicking on the small icons just above and left of the ground brush lets you choose terrain colour, the blue ones again control the brush shape For this lesson, please open the Empty World v01 world. THE ADD/REMOVE GROUND TOOL Press the ESC to bring up the Tool Menu. This will pause the game. Select the Ground Brush tool. You will see a flashing square on your terrain. This is your brush; this shows which part of the ground the tool will affect. You can change the size by using the right and left arrow keys. Let’s get started: - - Move the brush to where you want to create some terrain. You may want to zoom out using the mouse wheel. Adjust the size of the brush with the arrow keys Left click briefly Notice that you have created a new island You can hold down the mouse button while moving the mouse to continue adding terrain in a line. Deleting terrain is just as easy: - Page 16 Position your brush so that it overlaps existing terrain Right click Getting Started with Kodu CHOOSING TERRAIN TYPE Kodu includes many different building blocks for your terrain; terrain we call these blocks materials. Let’s pick a different material and using it to extend the world world. - With the Add Terrain tool selected, click the multi multi-coloured coloured blocks on the left side of the icon. A list of cubes will appear Scroll back and forth in this list using the arrow keys - Pick a material with the button (A on keyboard or left click.) Now that you have chosen a new material, create some more terrain using this material - Use the mouse wheel to zoom out a bit Hold down the left mouse button Move the left stick to paint new terrain HOW TO MAKE ROUGH OR CURVY GROUND The terrain you created above was flat – you may want something a bit more three dimensional. You can use the Up/Down tool we’ve already seen or you can get some more dramatic effects from the Roughen tool. The Roughen tool randomly changes the height of the terrain under the brush. It has two variants: spiky creates truly random, spiky effects, and hilly creates a more rounded, softer look. Use your world from the previous section ACTIVATE ROUGH OR CURVY TOOL Press the start button to bring up the Tool Menu select the Roughen tool. You will see a flashing area on your terrain. This is your brush; this shows which part of the ground the tool will affect. MAKE ROUGH OR CURVY GROUND Use the left mouse button to spike the terrain and the right mouse button to make the terrain hilly. While you could do this with the up/down tool and a very small brush, this tool makes it easier to add visual detail over a large area. If an area gets to spiky, you can smooth the terrain under the brush by pressing the middle mouse button. You can choose more brushes in the same way as the other terrain brushes. FOR FURTHER EXPLORATION Try using the rough/curvy tool to create different visual effects: Create an ocean with a jagged bottom and a smooth beach (see below for adding water). Make a world with a flat area, a smooth hilly area, and spiky mountains. Create a mountainous terrain with a narrow path going through it - perhaps by using the rough/curvy tool together with the flatten tool. Create a world with a mountain and a ramp that lets a character move from the bottom all the way up to the peak of the mountain. Page 18 Getting Started with Kodu HOW TO MAKE FLAT AREAS You will often find that you need a flat “arena” in which your gameplay can happen. The flattening tool makes it easy to level an area to a consistent height. PICK THE FLATTEN TOOL Press the start button to bring up the Tool Menu select the “Create Flat Areas and Ramps” tool. You will see a flashing area on your terrain. This is your brush; this shows which part of the ground the tool will affect. This brush behaves like the other terrain brushes discussed earlier. MAKE FLAT AREAS When you paint with the flattening tool, it looks at the height where you start painting and then raises (or lowers) everything the brush touches to that same height. If you start at a mountain peak and drag the brush across the terrain, you will create a flat area at the height of that peak. If you start in a deep valley, the brush will lower ground to that level. Move the cursor to the location where you would like to start flattening. Left-click to start flattening and hold it down while you move the mouse to paint a flat area. Notice that ground is lowered or raised as the brush touches it to reach the desired height. Page 19 Getting Started with Kodu ADDING WATER TO YOUR WORLD When you add water to a world, it is as though you are pouring the water onto the ground at a particular point; the water will pool in low-lying areas to form lakes and streams. Select the “Water Tool” tool. MAKE LAKES AND RIVERS Choose a spot to pour water onto the ground. Left click to add water at the cursor and right click to remove (lower) the water. Use this tool by moving the cursor anywhere where you want the water to rise or sink. Different bodies of water can have different types. If two bodies of water touch, they will take on the same appearance. Use the left mouse button on some water to raise the water level and the right mouse button to lower it. Notice how the water follows the shape of the terrain, pooling in lower areas and stopping at higher areas. There are different types of water. To change the type you are creating, click the coloured blocks above the Water Tool icon. This type will apply to any new water that you create. To change existing water to use this type, move the cursor over that water and press the middle mouse button (click the wheel) to set the type of that water. Page 20 Getting Started with Kodu BUILDING YOUR FIRST GAME IN KODU So far you’ve been tinkering with the tools that make up Kodu Game Lab. The next few pages are a step-bystep instruction in creating a basic, working videogame. A good way to learn about a new development environment is to attempt to clone an existing game that you are very familiar with. So we have chosen Space Invaders as our model to clone in the Kodu environment. If you haven’t played Space Invaders for a while, go to this link and play for a few minutes to remind yourself of all the various mechanics involved: http://www.freespaceinvaders.org/ GETTING STARTED Even with a game as simple as Space Invaders, and in an environment as intuitive as Kodu, there are fundamental steps of planning to be done before you start touching any of the tools. Planning saves you a lot of wasted time later on, and focuses your project so you can be sure you are done when you think you are done. With this project, we already have a template game to work from, so the planning stage is easier—the biggest reason to clone a game is to shorten your initial design time, and let you get into the development as quickly as possible! The process we will use throughout this course is fairly informal, but is most like the Rapid Prototyping Model. A prototype is a simple version built quickly to get to the play-testing stage as soon as possible. The process begins with some initial planning where we define our project goals and requirements. Our basic goal here is to create a reasonable copy of Space Invaders. Our requirements will be a checklist of mechanics, aesthetics and gameplay experience. The Analysis and Design stage breaks the larger ideas down into specific objects, characters, mechanics and level designs. Implementation is the point when you dive into Kodu and start building. As soon as you can, press Play and test the mechanic you’re trying to implement, and let the information you discover during play-testing influence the next round of design decisions and requirements. The cycle looks like this: Image from Wikipedia.org It is useful to take your game design apart, and build as many self-contained objects and mechanics individually, and test them as you go—rather than trying to build the whole game, and only then hit Play. We’ll find some opprotunities for isolated testing as we go. BASIC MECHANICS OF SPACE INVADERS A Basic Requirements Checklist: Page 21 Space Invaders consists of one screen/level area. The player is a single ship at the bottom of the screen. Getting Started with Kodu The ship can only move left and right. The ship can shoot upwards. The enemies are a field of aliens descending in a grid from the top to the bottom of the screen. The enemies move left and right as well as downward. The enemies ies shoot at the player. If the player is shot, the game ends. If the player is touched by an alien, the game ends. If the player shoots an alien, it is destroyed and the player gains some points. There are shields at the bottom of the screen the player can hide behind to avoid being shot, but won’t avoid being hit by the alien and destroyed. Sometimes special flying saucers go by the top of the screen for bonus points. So these mechanics we’ve analysed alysed from Space Invaders become our requirements list. A useful way to get started is to determine which objects the game consists of. The first object we will need is a game field, so let’s create a large square arena. Open an empty world. How big is large? Determine your proportions by placing your player’s ship on the empty field, and then use terrain painter tool to create a large square field beneath your ship. Next, reduce the size of your brush slightly, while keeping it centred on your bi bigg square. Change the material type to whatever you’d like the floor of your arena to look like, and paint another square, so you have two concentric squares, or one square with a different coloured border. Choose the Raise/Lower terrain tool and raise the he whole square a bit. Keep the entire block even by increasing the size of your brush so it is slightly larger than the square of terrain you’ve created. Switch to the ‘Magic Brush’ in the Terrain Raise/Lower tool, and with the same material as your inner square still selected, right-click click to lower the middle area of your arena. This should create a perfect square with four straight walls around the outside. Let’s program our first mechanic chunk. As mentioned above, we want to use small chunks of programming so we can test each piece as we go. For this step, we’ll work on the player/character. If you chose a saucer like I did, you’ll notice that your saucer is probably floating well above the floor of your arena. You can change its height by right clicking on it with the Object tool selected. Pro Tip: there are other ways to make walls. Especially if you want a nonnon square arena, use the Path tool and choose ‘wall’ instead of plain path, then raise the height of your Path to create a wall of whatever shape you desire! You can modify the path by clicking ng nodes and tweak the shape of your arena even after it’s built Position the saucer at the bottom of your arena, in the centre. Right click to open the programming panel and input the following code: This will cause the saucer to respond to the keyboard motion commands. Limiting the movement to East/West will cause it to only be able to move horizontally, if yyou ou have oriented the camera so that North is ‘up’ the screen. We also want our saucer to be able to shoot, so I’ll use the Space Bar for that. You’ll find Space Bar in the Misc sub-category of the keyboard. Let’s test these two mechanics and make any aadjustments as necessary. It’ss important to position your saucer well so that it is free to move in the arena. Try driving your saucer back and forth and shooting some blips. Hopefully you notice the problem straight away. Correct his wild aim by adding ng a ‘North’ modifier to the shooting rule. Kodu is such a fast programming environment that it is increasingly important to know what you want before you try to build it, or you’ll be caught in a never ending loop of ‘fiddling.’ It sounds so easy to just just jump in and start building—and and it is, but it’s also very easy to get lost playing with how the character shoots, and end up wasting time that should be spent on giving it something to shoot at, for example. It’s also good practice to get into because not all environments are as quick to implement and test as Kodu, and if you are spending time implementing features that are not in your requirements brief, you’ll waste far, far more time in those projects. CREATING ENEMIES Let’s create some enemies. In the original Space Invaders, the screen is fully fully-populated populated by a grid of aliens descending in a nice orderly fashion. I am going to change this up a little bit by populating the screen on on-thefly with enemies that will move along a path towards the play player, er, instead of in one big block. The effect should be a bit more dynamic game than the original. The game may also resemble Centipede a bit more than Space Invaders as a result. First, pick an object from the Objects Tool; I’m going to use a Wisp for th this is one because they look pretty cool when you make them glow. Add the object to the scene. Right-click click to change some of the Settings of the wisp. Firstly, let’s lower its health from 50 to 10 or 15 (remember the default value of your saucer’s blip bullets llets is 5 damage). Secondly, enable ‘Creatable’ in the settings list. Making the wisp creatable causes it to be classed as a template object, meaning the game can ‘create’ them on the fly. We don’t have to place each enemy we want to shoot in the stage age beforehand this way. This makes for a much neater program and some interesting random play. However, when you make something creatable, it also disappears from the stage when you hit Play. Something has to create it! Let’s use a Stick to create Wisps. sps. Use the Object tool to place a Stick in the top left corner of your arena. Sticks are the little turret-like like objects with a friendly name. Program the stick with the following: So now we have some code that will create a wisp for us. Test it out. Not very interesting, because the wisps don’t do anything! Let’s fix that. Firstly let’s change the height of those wisps to match your saucer. Now let’s give them their marching orders. For Space Invaders, we will use a Path to guide our enemies emies across the board. The path for this game is pretty simple, and looks like this: You can make more turns or fewer, but the last one needs to run right over your saucer. The path should be invisible when you press play, but if it’s not, check your world settings for Path Debugging and turn it off. Now ow let’s teach that Wisp to walk along the path. It’s as simple as: You’ll notice that we have no ‘When’ clause here, me meaning aning that wisps will always do this (until some other rule comes into play based on some other conditions). So if you test this, you should have the stick spitting out wisps that go racing down the path towards you. This is where the play testing comes in handy. You can see we already told the Wisp to move ‘slowly’ but if this is still too fast for your liking, you can slow it down more. Perhaps you think they are too tough— change their maximum health so you can kill them with one hit. Pro Tip: Kodu uses colour to designate different instances of objects. So the White path I’ve designated here is the white one we’ve drawn on the board. We can change the colour and so have different paths, and assign different properties based on that distinction. The score panels work much the same way. Now, the stick is spitting them out at regular intervals. I think this is pretty pretty boring. So let’s add the following to change it up a little. In the stick’ss program add: This will cause the stick to wait 1 second, then 0, 1 or 2 seconds more before shooting enemies. Play with the timing until you get something you like. You can even set up a second line of wisp creation with a different timer to make it more chaotic. At this point you should be able to ‘play’ your game. We haven’t implemented any scoring or failure mechanics though, so let’s do that now. Firstly, let’s add some value to shooting those wisps, by adding this rule to the wisp class. You’ll find the scoring variables in the Game menu category. Now what happens if the player messes up and gets hit by an enemy? That ends the game of course! So add this to the wisp as well. The wisps are still missing something: their own missiles. Add this rule: We’ve told the wisp to shoot the secondary weapon, the slow moving missile. Our board is level, so I’ve used the level command, that way when it hits the back wall it will explode rather than try to follow the altitude of the land, if you choose ‘cruise’ the missile can make its way over hilly landscapes. Be sure to configure the timing to create enough of a challenge, but not so much that the game is too hard. har Also, check the wisp’s settings to see how much damage each missile does. Do you want the player to be able to survive more than one shot, or is it one one-hit-kills? We also need to add a game-over over rule to the saucer when it’s hit by a missile. Now, if you play for long enough, eventually one of your wisps is going to shoot another one. That will probably cause one wisp to destroy the other—giving other giving the player free points! Let’s change that with this line of kode: So, whenever the shot hits a wisp, thee damage will be zero. zero There might be better ways to do this, especially if you want to introduce different enemies. This is a good time to do some testing. So now we have a scoreboard, but the game will go on forever! Let’s create an end condition. Attach this line to your player/character (in mine, the saucer). So now when we hit 20 points, the game is over and we win!! This is another obvious time to do some testing. Play the game through a couple of times and m make notes while you do so. Think about various settings: speed of the enemies, speed of your saucer. What about the speed that your blips are fired/reloaded? Is 20 points too long, or too short? Is this level easy enough to be level 1, or can it be madee easier? How would I make it harder? Finally, go back to the requirements list and check to see what’s missing. OTHER FEATURES Shields! Of course, the original cover system! Let’s add a shield to hide behind. First think about the properties of the e shields in the original: they will absorb enemy fire, but eventually get holes drilled in them. The player can also punch holes through them with his own shots, so they aren’t invincible. Kodu won’t let us make holes in objects, but we can approximate the deterioration of the shields using health. So let’s pick an appropriate object to act as a shield, how about a rock? They could be asteroids! Place a rock in your scene, and adjust its size to 2 or 3 so its big enough to be useful. Then check its maximum aximum health. This is where game balancing comes in, and where game documentation is important. How much health do your rocks have? How much damage does a wisp’s missile do? How much health does the rock have compared to the player’s saucer? These things hings all need to be balanced to make sense so that the rock can take a few hits before it blows up, but the player’s saucer can’t. So perhaps if the missiles have a damage of 50, and the player’s saucer is also 50 (so 1 shot destroys it), the rocks shoul should d have 200 health, meaning they’ll only last 4 shots. It really pays to have this stuff written down so you can check it all at once. We’ve only got 3 game elements here, what if we add 3 more enemy types with more than one kind of shooting capability? Whatever you decide as your balance, place two or three rocks in your arena that your player can hide behind. I suggest placing them in between the last 2 passes of the wisps so the enemies don’t run into them and get confused. Something we’ve hardly touched on is the look of this game. So far the level is pretty ugly. Let’s play with a couple world settings to change that! Firstly let’s set up the camera so we know what the player will be seeing each time. Click on the World Settings at the end of the Tool menu, and scroll to Camera. Choose Fixed camera, then click the X icon to set your Pro Tip: Saving in Kodu is a little camera’s position. This is the different to your average document perspective I’m using: editor. There is a built-in in version incrementation option so you can Now back in the World Settings ettings Menu, quickly sort through v00, v01, v02 of play with the Sky and Lighting settings the same project. Take a close look at until you find something atmospheric. the save screen by pressing Home on I’m going for the sci-fi fi space aesthetic so the keyboard, or clicking the house on I’ve chosen some fairly dark settings. the Tool palette. That will make the glowing of my objects stand out more, but I should probably add some lights to make things a bit more visible. RESULTS At this point you should have a working version of a Space Invaders-like game. There are a lot of things that could be added to it, of course, but many of the basics of gameplay and the functions of Kodu have been covered here. Feel free to experiment with this design and learn more. ASSIGNMENT NOTES We have referred to this design as being worth a Credit, but that isn’t entirely true. To get a credit with this design, you’ll need to add at least one more enemy type to increase the difficulty at some point in the game. You would also want to spend some time on the aesthetics, as indicated above. Even then, this would only be a low credit. To get higher marks, we’d like to see something other than a straight clone of a primitive game. Add something innovative, or polish it until it really shines. It also assumes that the accompanying documentation with this game is of a very high standard. You can’t make a great game and provide terrible documentation for this course. Both are important parts of the process. Page 28 Getting Started with Kodu
© Copyright 2026 Paperzz