Kodu Game Lab – 3D Games Design for School

kodu-game-logo

Kodu is a new game programming language / tool from Microsoft.  It has had a very low-key launch, I came across it as it was featured in the excellent Edge Magazine last month.  Kodu is initially available to the public on X-Box Live Marketplace for about £3.50.  I have been fortunate enough to be allowed on to the Beta of the PC version, this is currently only open to educators.  You can apply to join the Beta by following the link from this MSDN blog.  Watch this video from Microsoft, it gives you a quick feel of how the program works:

Kodu demonstration for schools
Kodu demonstration for schools

I have spent the whole morning working through the tutorials and examples getting a feel for what is possible and I have to say I am impressed by the scope of the package.  I’m also a little bit overwhelmed.  So I decided to try and build the bare bones of a game from scratch.  I chose a tower defence style game as the mechanics of it are simple enough.  What follows is a quick run through of my progress so far, I hope it serves as a good enough introduction of Kodu.

Terrain:

Terrain menu

Terrain menu

There are a number of terrain building tools allowing you to raise/lower the ground, add water, smooth edges and lay different terrain types.  So the first thing I did was make a simple square of land, surrounded with water and with a road laid on top.

Paths:

All tower defence games have a path along which the invading enemy hordes must walk.  The easiest way to make any game character follow a certain route is to add a path.  You can see the path joining the yellow nodes on the next screenshot.  I’ll come back to this when I have a character.

Path via yellow nodes

Path via yellow nodes

Control:

You map the controller to move any of the objects / characters you add to the game world.  I tried a number of control methods, the default is to add a Kodu, a slow creature who walks around.

Add a Kodu

Add a Kodu

I tried adding one of these and then having him walk over to a tower, pick it up and place it where it was required.  This all seemed a bit ungainly.  I decided I really just needed a cursor of sorts with which I could click on the screen to add a tower.  To make a cursor you still need to add an object, so I chose the flying saucer and made it move with the left analogue stick.

Saucer

Saucer

Programming:

How you ask?  Hitting Y brings up the meat of Kodu, it’s visual programming language.  Below are the commands programmed in for my flying saucer cursor:

Code for Saucer

Code for Saucer

That first line is all that’s needed to make the saucer fly in whichever direction you move the analogue stick (X-Box controller is required – even for PC).  I’ll get onto the rest shortly.

Baddies:

I wanted a steady stream of baddies to walk through the level, it took a little bit of fiddling to work out how to do this.  I chose a character called the Cycle which is a little robot uni-cycle.  After creating him I needed to go into his options by hitting X and then making him ‘Createable’, this meant I could create him from the code of other objects.  There’s a handy help menu for every single option.

Options menu

Options menu

Help menu

Help menu

I programmed my Cycle to follow the yellow path which I created earlier and to shoot at the towers on sight.

Cycle Code

Cycle Code

I added a ‘Hut’ at the start of the level and programmed it open every 10 seconds, ‘create’ a Cycle of a random colour, and make a noise while it was at it.

Hut

Hut

Hut Code

Hut Code

Towers:

Just like the baddies I made a ‘createable’ tower from the ‘Stick’ character, one that naturally just sits and shoots, perfect for the job.  I programmed it to turn towards and shoot rockets at the cycles.

Tower code

Tower code

If you look back at my code for the Saucer you will see I added a line that creates a tower each time A is pressed on the pad.

Points:

No game is complete without a scoring mechanic.  Kodu makes it easy to change the score via any event.  First thing I did was add a cost of 20 points for creating a tower which you can see in the Saucer code.  All well and good, but Kodu happily let me build loads of towers sending the points off into a world of negativity!  To stop this I had to get a little creative, I added the following code which checked if the score was below zero, and if it was moved to the second screen of code for my Saucer.

-ve points switch to code screen 2

-ve points switch to code screen 2

Code page 2

Code page 2

Once switched to this second screen Kodu will only run these instructions on your character.  As you can see I removed the ability to create towers whilst below zero and added a line of code to switch back to code screen 1 when the score returned above zero.  This is great for changing the behaviour of an object based on some event.

This created another problem, I started with no points which meant at the start of the game you could only build one tower.  There was no option to start the score from anything other than zero.  To get around this I added a ‘Star’ object on top of the Saucer, as soon as the game starts the Saucer ‘eats’ the Star, and you get 50 points, problem solved! (See original Saucer code).

Points scoring was then programmed in via the Cycles:

Points code

Points code

If the Cycle is destroyed by your Towers you get 20 points, if it makes it all the way to the end of the level alive and touches the Castle I placed there you lose 10 points.

Action:

And here’s the finished game in action: EDIT *Video problems uploading – I’ll post the video soon*

As you can see there is much tweaking needed, you can adjust damage and health levels and the like to balance your game.  If I continued with this I would make additional towers and baddies and sort out the scoring so there is a game-over of some description.  I hope this has given you a small flavour of Kodu and scratched the surface of what is possible.

In School?

So could I see this being used in school? Yes, for sure, but with some caveats.  It has a steeper learning curve than I was expecting and would be hard work with a class full of kids.  Although I could be wrong and they could take to it like ducks to water.  One obvious place for it is in the ‘Control’ part of the ICT curriculum.  I haven’t taught ICT yet myself, so I don’t know if it would tick all the boxes required, although I guess it would.  Whether it would be an efficient way to cover the work I doubt, but it sure would be fun!  There is obviously logic and programming galore in here, so wherever that needs to be taught Kodu is a possibility.  I think my next challenge will be to think of some Maths based uses, there is obviously lots of potential here.  Where Kodu will I’m sure shine is in after school / lunchtime clubs.  With a smaller group of interested pupils you could have great fun in this environment.  Once you get in the swing of things, with a basic game set up, the process of balancing the game with points, health, weapons etc becomes an interesting insight into the games design process.  I think were I to give this to pupils to work with I would start them off with a suitable example, such as the one I have just made, and ask them to develop it from there.  It’s much easier to get the hang of the whole system when you have an existing game to play around with.

All in all Kodu is an exciting development and sits nicely alongside Scratch as a tool for looking at programming and games design.