I have tried a few games that you can play with two Calliope mini with the help of the wireless module in pairs of two. This project is not very easy to set up but if you like you can copy the code without understanding it completely and just play it.
Bring the code to both Calliope mini and supply both with power. The game starts as soon as a player presses button B. From this point on you can move your bar to the left with button A and to the right with button B.
The player who started the game with button B will get a ball (one point). If the ball disappears at the upper end of the diplay it will appear at the top of the opponent's Calliope mini. The ball must not touch the lower end of the display and must be prevented from doing so with its own bar.
If the ball touches the lower end of the display, the player on whose side the ball was loses. The other player wins. To start a new round, the reset button must be pressed on both Calliope mini.
ABOUT THE CODE
To program the Calliope mini I used the MakeCode editor.
direction_x determines whether the ball moves to the left (-1) or to the right (1).
direction_y determines whether the ball moves upwards (-1) or downwards (1).
x & y are the coordinates of the current position of the ball.
bar_x is the x-coordinate of the left edge of the own bar.
The game status is set to 0 in the beginning, so the Calliope mini waits for the game to start.
THE CONTINUOUS LOOP
The pause determines the beat, meaning the speed at which the ball moves. Smaller pause = higher beat = faster game.
In the next two lines the ball is moved by changing the x- & y-coordinate according to the direction of motion.
If the ball touches the left or right edge of the display, the horizontal direction is reversed. In this case, the ball has already rolled out of the display internally, which is why the horizontal position must be adjusted after the change of direction before the new position of the ball is shown on the display.
If the ball reaches the bottom of the display, two events can occur. If the bar is directly below the ball, the vertical direction is reversed. If the bar is not below the ball, the player loses and a message is sent to the other Calliope mini.
If the ball reaches the upper end of the display, the ball changes from one Calliope mini to the other. For this, something has to be converted because if the ball disappears in the upper left corner of the mini1, for example, it has to appear in the upper right corner of the second mini. Also direction_x has to be reversed (direction_y is always 1 (downwards) in this case).
To bring the ball over, a name-value-pair is sent, where name is the x-coordinate of the ball (only as string) and value is the horizontal direction of the ball.
After all motions of the ball have been dealt with, the new position of the ball and the bar can be shown on the display.
For this we first switch off each pixel in the two green loops and then switch on one pixel for the ball and two pixels for the bar again.
If the status is not 1 the Calliope mini will not calculate big but show a smiley showing if you won or lost.
OUTSIDE THE PERMANENT LOOP
If button A is pressed, the position of the bar changes by 1 to the left.
If button B is pressed, the position of the bar changes by 1 to the right.
If the Calliope mini is waiting for the game to start, it starts it and sends a message to the second Calliope mini.
Three different types of messages can arrive at Calliope mini.
If value = 137 the other player has lost and the Calliope mini who receives this message has won.
If value = 11 then the game was started from the other Calliope mini.
In any other case, the new position of the ball is communicated when switching between the Calliope mini. To bring the ball over, a Name-Value-Pair is sent, where Name is the X-coordinate of the ball (only as string) and Value is the horizontal direction of the ball.
A visual demonstration of this project can be seen on YouTube popup: yes.