===== Rock-Paper-Scissors ===== A digital version of the Rock-Paper-Scissors version allowing you to play against each other or against the computer. {{:en:rockpaperscissors2.jpg?direct&400|}} To program this example you need to use the buttons, the matrix, variables, logic, and math. ==== Programming ==== You can program the game progressively. For each step, add the displayed blocks and put them in the right order. You can then test your program by clicking on {{:en:instructions:play.png?direct&30|}}. === Step 1: Showing a number when a button is pressed === * You will say to Kniwwelino: « //If I press button A then write "1" on the matrix// ». Use the following blocks and add them to ''Kniwwelino loop forever'': {{:en:instructions:wristband03.png?direct|}}\\ {{:en:instructions:rockpaper01.png?direct|}} \\ === Step 2: Showing a random number when a button is pressed === * You will say to Kniwwelino: « //If I press button A then choose a random number between 1 and 3 and write this number into a variable named ''value''// ». Add the following blocks to your program: {{:en:instructions:rockpaper02.png?direct|}}\\ {{:en:instructions:rockpaper03.png?direct|}} * After Kniwwelino chose a random number between 1 and 3, you will say to Kniwwelino: « //Show the variable ''value'' on the matrix// ». Remove the ''1'' and replace it with ''value'': {{:en:instructions:rockpaper11.png?direct|}}\\ {{:en:instructions:rockpaper05.png?direct|}} === Step 3: Showing different images for the numbers 1, 2, and 3 === Instead of writing the number in ''value'' to the matrix, you will now say to Kniwwelino: « //If the number in ''value'' is equal to ''1'', then show an image (e.g. a rock). If it is equal to ''2'', then show another image (e.g. a paper). If it is equal to ''3'', then show a third image (e.g. scissors).//». * Delete the block writing the number {{:en:instructions:rockpaper12.png?direct|}} * Replace it with your first condition made of the following blocks. {{:en:instructions:rockpaper08.png?direct|}}\\ {{:en:instructions:rockpaper09.png?direct|}}\\ {{:en:instructions:rockpaper05.png?direct|}}\\ {{:en:instructions:rockpaper07.png?direct|}}\\ {{:en:instructions:rockpaper10.png?direct|}} * Repeat the previous point for the two other conditions. ==== Solution ==== [[en:instructions:rockpaper_solution1|]] or open in [[https://code.kniwwelino.lu/?xml=examples/RockPaperScissorsV1.xml|KniwwelinoBlockly]] Print versions available for download in [[en:downloads:start|]]. ==== Crafting ====