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.
Press the pen on the Ruby tab.
Select the different Ruby skins: Ruby back, Ruby right, Ruby left.
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.
Press + and search for Labyrinth.
Select one and click Confirm.
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.
In the Events tab, drag the block when up is pressed.
In the Movements tab, drag the block move 0 steps up and place it inside the event block.
Change the value 0 to 1.
In the Style tab, drag the change skin to block.
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.
In the Events tab, drag the block when Run ▶ is pressed.
In the Control tab, drag the repeat forever block and place it inside the event block.
On the Control tab, drag the if block and place it inside the forever repeat.
In the Sensors tab, drag the touching color block and place it in the false space.
Change the red color to black (the RGB values must be exactly R:0 G:0 B:0).
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.
In the if block, press + twice, and delete the last if by pressing -.
Final result:
In the Sensors tab, drag the block colliding with and place it in the false space.
If it isn't, change it to colliding with finish line (or whatever you've named your final sprite).
In the Style tab, drag the say block for 0 seconds and place it inside the if not.
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.
Repeat the steps to create a new sprite, add it to the game and place it in a location of your choice.
On the Events tab, drag the block when Run ▶ is pressed.
On the Variables tab, drag change variable block to and place it inside the event block.
Click on the arrow next to the variable and create a new one by clicking on plus.
Name the points.
In the change points to block, type 0 in the text box.
On the Variables tab, dragging the block show points and placing it after the block change points to 0.
On the Control tab, drag the repeat forever block and place it inside the event block.
On the Control tab, drag the if block and place it inside the repeat forever block.
In the Sensors tab, drag colliding with block and place it in the false space.
Change it to colliding with Ruby, (or the name you gave your character).
In the Style tab, drag the hide sprite block and place it inside if.
In the Variables tab, drag the change points to block and place it after the hide block.
On the Operators tab, drag the 0 plus 0 block and place it inside the text box of the change points to block.
On the Variables tab, drag the points block and place it on the first 0.
Change the second 0 to 1.
You can also add another sprite to lose points, just repeat the same steps and replace the + with -.