Skip to content

Instantly share code, notes, and snippets.

@shawngrimes
Created July 19, 2018 13:39
Show Gist options
  • Save shawngrimes/346bfd6779cb1df7a457a204067ecd07 to your computer and use it in GitHub Desktop.
Save shawngrimes/346bfd6779cb1df7a457a204067ecd07 to your computer and use it in GitHub Desktop.
Tri-Word Game Microbit game code from MEC Bootcamp 2018 created by Kathy Lane and Shawn Grimes as a prototype activity.
let letter = ""
let timerCounter = 0
//Creates a shake gesture that will display a new letter
input.onGesture(Gesture.Shake, () => {
if (timerCounter < 63) {
//Uncomment one of the below depending on what letters you want added to the microbit
letter = "AEIOUY".charAt(Math.random(6))
//letter = "BCDFGHJKLMNPQRSTVWXZ".charAt(Math.random(18))
//letter = "ABCDEFGHIJKLMNOPQRSTUVWXYZ".charAt(Math.random(25))
//Shows the letter on the display
basic.showString(letter)
}
})
//Starts a 63 second timer
while (timerCounter < 63) {
basic.pause(1000) //pauses for 1 second
timerCounter = timerCounter + 1 /increments the timer counter
}
//Game is over after timer ends so show a skull on the display.
basic.showIcon(IconNames.Skull)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment