Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
en:instructions:rockpaperscissors2 [2018/06/28 09:39]
kniwwelino
en:instructions:rockpaperscissors2 [2018/06/28 10:43] (current)
kniwwelino
Line 1: Line 1:
 +===== 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.
  
 +{{ :en:rockpaperscissors_v2.jpg?direct&400 |}}
 +
 +==== Programming ====
 +
 +  * Create two variables in ''Kniwwelino on start'' to store your score and the one of your friend: ''myScore'' and ''yourScore''.
 +
 +{{:en:instructions:rockpaper_v2_01.png?direct|}}
 +
 +  * Create a group for exchanging messages.
 +  * Connect the variable ''yourScore'' to the topic used by your friend to send his/her score: ''GAME/friendA''.
 +
 +{{:en:instructions:rockpaper_v2_02.png?direct|}}
 +
 +  * 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 topic ''GAME/friendB''.
 +
 +{{:en:instructions:rockpaper_v2_03.png?direct|}}
 +
 +  * As in the [[en:instructions:rockpaperscissors|original version]], you now check the score and display an icon on the matrix representing the rock, the paper, or the scissors.
 +
 +{{:en:instructions:rockpaper_v2_05.png?direct|}}
 +
 +  * 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 ''myScore'' and ''yourScore'') and color it in blue (if equal), green (if you won), or red (if your friend won).
 +
 +{{:en:instructions:rockpaper_v2_04.png?direct|}}
 +
 +  * Use the same code for the Kniwwelino of your friend, but replace ''friendA'' with ''friendB'', and vice-versa for the topics. Your friend then attaches a variable to topic ''GAME/friendB'', and sends the own score to topic ''GAME/friendA''.
 +
 +{{:en:instructions:rockpaper_v2_06.png?direct|}}
 +
 +\\
 +=== 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 [[https://code.kniwwelino.lu/?xml=examples/RockPaperScissors_withScore.xml|KniwwelinoBlockly]]
 +
 +[[https://code.kniwwelino.lu/?xml=examples/RockPaperScissors_withScore.xml|{{:en:instructions:rockpaper_v2_solution1.png?direct|}}]]
 +
 +[[https://code.kniwwelino.lu/?xml=examples/RockPaperScissors_withScore.xml|{{:en:instructions:rockpaper_v2_solution2.png?direct|}}]]
  • en/instructions/rockpaperscissors2.txt
  • Last modified: 2018/06/28 10:43
  • by kniwwelino