Rock Paper Scissors version 2
This is an extended version of the Rock Paper Scissors game, where two Kniwwelinos communicate with each other to give feedback who has won: the RGB LED lights up in green for the winner, in red for the loser, and in blue in case both are equal.
Programming
- Create two variables in
Kniwwelino on startto store your score and the one of your friend:myScoreandyourScore.
- Create a group for exchanging messages.
- Connect the variable
yourScoreto the topic used by your friend to send his/her score:GAME/friendA.
- Each time button A is clicked, both scores are first reset to 0, and the RGB LED is switched off. Then, there is a countdown as a delay to make sure the score is not calculated before your friend has pressed the button too (and reset his scores). After that, the own score (
myScore) is calculated randomnly and send via a message to the topicGAME/friendB.
- As in the original version, you now check the score and display an icon on the matrix representing the rock, the paper, or the scissors.
- Finally you want to light the RGB LED in the right color. For this, you need to check the value of both scores (stored in
myScoreandyourScore) and color it in blue (if equal), green (if you won), or red (if your friend won).
- Use the same code for the Kniwwelino of your friend, but replace
friendAwithfriendB, and vice-versa for the topics. Your friend then attaches a variable to topicGAME/friendB, and sends the own score to topicGAME/friendA.
Solution
This is the entire solution for one of the players. For the second player, just replace friendA with friendB and vice-versa.
Open project in KniwwelinoBlockly








