Subscribe Now: Feed Icon

Saturday, April 16, 2011

Game Programming with Kodu

Part of the Beginner Game Programming in .Net series.

Kodu is a “new visual programming language made specifically for creating games”. I heard about Kodu back in 2009 but back then I didn’t have time to explore it. Kodu is game design engine designed like a game it self.

This is a Kodu

The advantages of using Kodu are:

  • Really easy
  • Free
  • Fun: treat as a puzzle
  • Can be played on XBox
  • Doesn’t need Visual Studios
  • Can be exported (and thus played on another PC)

The disadvantages of using Kodu are:

  • Cannot be converted into a standalone application
  • Not really .Net – implemented in .Net since it needs the XNA Framework but implementing games without a .Net language such as C# (disadvantage just because it’s part of the requirements)



Download and install Microsoft XNA Framework Redistributable 3.1

Download and install Kodu Game Lab


Getting Started

Open: Desktop –> Kodu Game Lab

Or:     Start –> Programs –> Microsoft Research –> Kodu Game Lab

The best way to get started is to go over the tutorials, on the main menu click on Load World and start the First Tutorial:


and select Play.

This tutorial is just for making the Kodu move by your input. The controls are very easy and just made me remember a game I played as a kid: TIM (The Incredible Machine) but if in TIM the task to perform was predefined here you can just choose it.


The Basics

Kodu is a game platform for interactions, it is fairly easy to program the Kodu into a shooter or a race. But add in logic and it starts to become tough.

There are no ifs, the objects are interacted by: Event => Action

So how do a Programmer programs Kodu?

Well… The first insight is that we have variables: the score boards! (we have 11 colors and 26 letters of scores)

Another insight is that there is a GOTO mechanism: switching the pages

There is even a compare of the score in the score boards – though it is of a const value…



I was actually not sure if a Tic-Tac-Toe game can be created in Kodu (since it is a game platform for interactions) but then I saw this video… And I was starting to think of implementing a Wacky Wheels instead…


How to create a turn based game?

The easiest way I found was using the Score Boards and pages:

Player 1 is with score 0 in the white score board

Player 2 is with score 1 in the white score board


Player 1: Plays and when his turn ends changes the score to +1


Player 2: Waits for a score of 1 all the while complaining about how slow the other player is:


When it’s Player 2 turn: He plays and in his end of turn subtracts 1


The player’s pages are complete opposites, player 1 will wait in page 2 and play in page 1 while player 2 will wait in page 1 and play in page 2.


How to create a winning logic?

If we had a matrix it would have been easy, just check for the winning conditions.

But we don’t have a matrix – we do have integers and can use them as score boards:








Each letter is a score board.

When player 1 plays he adds 1 to the variables he effects.

When player 2 plays he adds 10 to the variables he effects (I started out with subtracting 1 but then found out you just can’t check for a score of –3).

For example: Player 1 colors the spot in the top left corner. So he adds 1 to A, D, G.




We shall know that a player won when a variable has either 3 or 30, and from that we shall know which player won…

Checking for a winner is done by inanimate object like a tree:


And setting the winner:



The game:


To make it more interesting I made the players are moving really fast:


Classic winning move by the red player:


And the winner is:


The example can be downloaded from my CodePlex samples in here (a zip download of the Kodu).


Now I don’t consider Kodu a real programming Framework. This tutorial was done both because I wanted to try Kodu out for some time and to help my cousin. But it made me think because there were so many things that I have grown used to in programming like loops, variables and even real debugging (I had a bug while programming of switching to a non existing page and the program simply went back to the first page and that just caused an infinite loop).

It got me thinking of old games which is definitely a plus (and I might just come back to it just give a rebirth to Wacky Wheels).

So even if you are a programmer do give it a try because it will get you thinking in some strange ways. If you have kids (or cousins) try it out with them – it does make the brain work while having fun…


Microsoft Research: Kodu

Game programming made easy

Planet Kodu – checkout the games section or the challenges


Keywords: Kodu, Game programming

IceRocket Tags: ,