Steady hand game

Step 1 /8


The emulator will show the status of CodeBug’s legs with blue arrows.

To turn this feature on, click on the cog at the top right of CodeBug.

Tick the Show leg controls box.

Click Apply button.

An arrow pointing towards the leg is an input, away from the leg is an output.

Step 2 /8

Configure leg

To sense the wand and course touching, we need to configure CodeBug’s leg 1.

Click the cog on your start block.

In the window that appears, tick the checkbox next to leg 1 input/output. Click the cog again to close the window.

Step 3 /8

Set to input

We want to set leg 1 to a digital input.

Select the drop down menu next to “leg 1 as” on your start block, and select digital input.

Step 4 /8

If condition

We want CodeBug to run different code depending on if a leg’s circuit is complete. To do this we need an if block.

From the If menu drag in an if block onto an empty space on your workspace.

From the Inputs/Outputs menu drag a leg grounded block and snap it to your if block. Click the block’s drop down menu to change the leg to 1.

Step 5 /8

Conditional code

We need different code to run if the circuit is complete. Any code inside the if block will only run if the condition of the if block is true (leg 1 is connected to ground).

In your If block, put a scroll sprite block.

Now attach a get string sprite block into the scroll sprite puzzle piece.

Change its text from Hello world to Game over.

Step 6 /8

While loop

Now you need to make your code repeat so that CodeBug can continuously detect the input.

From the Loops menu, drag a repeat while true loop and snap it onto your start block.

Then drag your if block into this while loop.

Step 7 /8

Run your code

Click the Play button to run your code. The message will scroll while 1 leg is clicked.

Step 8 /8

Download your code

Click the Download button to download your program. Make sure to follow the download to CodeBug tutorial to load your program onto your bug.