Eh, everybody might heard of the “rock scissors paper” game: it is a hand game, usually played between two people, in which each player simultaneously forms one of three shapes with an outstretched hand. These shapes are “rock” (a closed fist), “paper” (a flat hand), and “scissors” (a fist with the index finger and middle finger extended, forming a V).
A player who decides to play rock will beat another player who has chosen scissors (“rock crushes scissors”), but will lose to one who has played paper (“paper covers rock”); a play of paper will lose to a play of scissors (“scissors cuts paper”). If both players choose the same shape, the game is tied and is usually immediately replayed to break the tie.
Lets play this game using a Micro:bit board!
Will have to set the “on shake” event when to choose the sign, and display the sign on the led matrix.
Use the online editor https://makecode.microbit.org/#editor to make the program.
First clear the screen, set a variable “hand_sign” with a random value from 1 to 3 (1-scissors, 2-rock, 3-paper);
Then for the corresponding sign, draw an image
Here is the gameplay on the simulator:
Use the following JavaScript code in the editor if you are lazy to make the sketch from zero:
let hand_sign = 0 input.onGesture(Gesture.Shake, function () { basic.showLeds(` . . . . . . . . . . . . . . . . . . . . . . . . . `) basic.pause(500) hand_sign = Math.randomRange(1, 3) if (hand_sign == 1) { basic.showLeds(` # # . . # # # . # . . . # . . # # . # . # # . . # `) } else if (hand_sign == 2) { basic.showLeds(` . . . . . . # # # . . # # # . . # # # . . . . . . `) } else { basic.showLeds(` # # # # # # . . . # # . . . # # . . . # # # # # # `) } }) hand_sign = 0 basic.showIcon(IconNames.Square) basic.pause(500) basic.showIcon(IconNames.SmallSquare) basic.pause(400) basic.showIcon(IconNames.SmallDiamond) basic.pause(300) basic.showLeds(` . . . . . . . . . . . . # . . . . . . . . . . . . `)
I’ve added some fancy stuff on start event:
Get your fun toy: