Skip to main content
All Collectionsubbox
How to create a labyrinth in ubbox
How to create a labyrinth in ubbox

Learn how to create a labyrinth in ubbox

Sara Batista avatar
Written by Sara Batista
Updated over 6 months ago

A labyrinth is one of the simplest games to build on the ubbox. To build it, just follow these steps:

The first thing you have to do is choose the sprites for the game. These are just examples. Choose the ones you like best, depending on the theme of your game.

  1. Press the pen on the Ruby tab.

  2. Select the different Ruby skins: Ruby back, Ruby right, Ruby left.

  3. Click on Confirm.

This will be necessary so that when we walk, Ruby turns in the right direction.

Note: the size of the sprite can be adjusted to fit the size of the labyrinth if necessary. You can adjust it by dragging the sprite's properties around it.

Next, let's add the Labyrinth.

  1. Press + and search for Labyrinth.

  2. Select one and click Confirm.

  3. Repeat the same steps above to add the finish line. The finish line must be at the end of the labyrinth and cannot only be black.


Sprite movements

Go back to the Ruby tab and let's program the game.

  1. In the Events tab, drag the block when up is pressed.

  2. In the Movements tab, drag the block move 0 steps up and place it inside the event block.

  3. Change the value 0 to 1.

  4. In the Style tab, drag the change skin to block.

  5. Click on Ruby and change it to Ruby back.

So, when the character walks upwards, he will stand with his back to us. The up key on your keyboard has been programmed. Now you need to repeat the steps above to change the other keys for the other directions (down, left and right).

Programming the collision

Next, let's program the Ruby's reactions if it collides with the black lines in the labyrinth.

  1. In the Events tab, drag the block when Run ▶ is pressed.

  2. In the Control tab, drag the repeat forever block and place it inside the event block.

  3. On the Control tab, drag the if block and place it inside the forever repeat.

  4. In the Sensors tab, drag the touching color block and place it in the false space.

  5. Change the red color to black (the RGB values must be exactly R:0 G:0 B:0).

  6. In the Control tab, drag the reset position block and place it inside the if block.

Let's now program what happens when Ruby collides with the finish line you've chosen.

  1. In the if block, press + twice, and delete the last if by pressing -.

    Final result:


  2. In the Sensors tab, drag the block colliding with and place it in the false space.

  3. If it isn't, change it to colliding with finish line (or whatever you've named your final sprite).

  4. In the Style tab, drag the say block for 0 seconds and place it inside the if not.

  5. Write "I won!" in the text box and change 0 to 2.

Adding points

Now we're going to add a sprite, which must be caught by our character in order to earn points.

  1. Repeat the steps to create a new sprite, add it to the game and place it in a location of your choice.


  2. On the Events tab, drag the block when Run ▶ is pressed.

  3. On the Variables tab, drag change variable block to and place it inside the event block.

  4. Click on the arrow next to the variable and create a new one by clicking on plus.

  5. Name the points.

  6. In the change points to block, type 0 in the text box.

  7. On the Variables tab, dragging the block show points and placing it after the block change points to 0.

  8. On the Control tab, drag the repeat forever block and place it inside the event block.

  9. On the Control tab, drag the if block and place it inside the repeat forever block.

  10. In the Sensors tab, drag colliding with block and place it in the false space.

  11. Change it to colliding with Ruby, (or the name you gave your character).

  12. In the Style tab, drag the hide sprite block and place it inside if.

  13. In the Variables tab, drag the change points to block and place it after the hide block.

  14. On the Operators tab, drag the 0 plus 0 block and place it inside the text box of the change points to block.

  15. On the Variables tab, drag the points block and place it on the first 0.

  16. Change the second 0 to 1.

You can also add another sprite to lose points, just repeat the same steps and replace the + with -.

Did this answer your question?