2_player_preview-2.gif

You can also create games for two people by using the multy touch screen of your phone. The person who taps faster on the button, wins the race. Let’s play!
Download the program

What bricks and objects do you need?

Create a new program and add the following objects from the media library:

preview_object

Now add these scripts to the move button 1 object:

1. Step

button1_object

Position the first button in the upper left corner. Also set the size to a value you like.

button1_1

 

2. Step

If the button is tapped by the first player, the button sends the message “move1” to all other objects. Only rabbit 1 will react to this message.

button1_2

Now add these scripts to the move button 2 object:

3. Step

button2_object

Now add the object move button 2 for the second player. Position it in the upper right corner of your screen.

button2_1

4. Step

When the move button 2 object is tapped, the message “move2” will be sent to all objects but only rabbit 2 will react to this message.

https://catrobatblog.files.wordpress.com/2017/10/button2_2.png?w=320&h=197

Now add these scripts to the Rabbit 1 object:

5. Step

rabbit1_object

Download these two looks from the media library.

rabbit_looks

6. Step

First position rabbit 1 in the lower left corner.

rabbit1_1

7. Step

When the first button is tapped, the “move1” message is sent. If this happens rabbit 1 should react. The when you receive-brick allows you to communicate between objects. Now rabbit 1 changes it y-value by 20 and switches to its next look.

rabbit1_2

 

Now add these scripts to the Rabbit 2 object:

8. Step

rabbit2_object

Download these two looks from the media library.

rabbit_looks

9. Step

Similar to rabbit 1, position rabbit 2 in the lower right corner. Additionaly change the color for a different appearance.

rabbit2_1

10. Step

Only when move button 2 is tapped and than the message “move2” is sent, the rabbit 2 changes it´s y-value and takes the next look.

rabbit2_2

Now add these scripts to the goal line object:

11. Step

goalline_object

The object goal line needs three different looks. One look is for the goal line itself and the other two looks are for the winning screen of the game. Draw these looks with Pocket Paint. You can additionaly use images from the media library.

goalline_looks

goalline_win1

goalline_win2

goalline_line

12. Step

When rabbit 2 touches the goal line, set the you win rabbit 2 look.

goalline_1

13. Step

On the other side when rabbit 1 touches the goal line, the object should take the other win look.

goalline_2