BBC micro:bit
Using Buttons A & B

Introduction

In a Kodu world, you can detect when the A & B buttons on the micro:bit are pressed and make something appropriate happen. This page describes how to set up the very simplest of Kodu worlds where you use the buttons to make the Kodu character move.

A Simple World

Start Kodu Game Lab and make a new world to act as a test environment for you.

Click on the character/object button at the bottom of the screen to add a Kodu character to the world,

Kodu World

Click on the character to move it into position somewhere over the terrain of your world. Use the left mouse button to drag the character into position.

Kodu World

Click with the right mouse button on Kodu to program interactions. Choose Program from the menu of options.

Click on the + buttons to add the tiles that make up each of the statements. Try out the following tiles,

Kodu World

Press the escape key until you are able to run the Kodu world. Pressing the A and B buttons should cause Kodu to turn to the left or right. That's not really making the character move. Let's try out another approach.

Go back to the program code for Kodu by clicking with the right mouse button on the character and choosing program from the menu. Edit the second statement so that pressing the B button will cause Kodu to move forwards,

Kodu World

Try this version out. If Kodu won't move forwards or starts falling, it is because the character is not positioned properly above the terrain.

Challenges

  1. This is quite a simple technique and would be suitable for a game world where most things are achieved by moving. This would suggest a maze game. The Game Maker section of this web site has a tutorial for making a maze game called Blue Balls Of Evil. There is an explanation and some screenshots of the game on those pages that might inspire you to try to make a simple 3D version. You will need to tweak the speed of the movement a little, work out how to make the balls move the way you would like and write statements to handle the collisions between the character and its enemies.
  2. This technique is pretty easy to add to an existing game world where all you do is move the character to achieve the main game goals.

...And Fire

One final edit to make is to use one of the buttons to make Kodu fire a blip. Change the second program statement so that it now reads like this,

Kodu World

Challenge

  1. See if you can add some enemies to the world to make something that could be played like this. Place Kodu in the centre of the world and have enemies approach from all directions trying to touch Kodu. Assign points for each time an enemy is shot and killed. When an enemy is killed, it should respawn in its starting position.