Skip to content

Instantly share code, notes, and snippets.

@gildotdev
Created June 13, 2018 14:58
Show Gist options
  • Save gildotdev/a4f218d24b20b5adceebc69aa848947d to your computer and use it in GitHub Desktop.
Save gildotdev/a4f218d24b20b5adceebc69aa848947d to your computer and use it in GitHub Desktop.
let Hits = 0
let Health = 0
input.buttonB.onEvent(ButtonEvent.Down, function () {
if (Health == 1) {
pins.A7.digitalWrite(true)
network.infraredSendNumber(Colors.Black)
pins.A7.digitalWrite(false)
}
})
network.onInfraredReceivedNumber(function (receivedNumber) {
pins.A7.digitalWrite(true)
if (Hits == 9) {
Health = 0
}
if (Health == 1) {
light.setPixelColor(Hits, receivedNumber)
Hits += 1
} else {
light.setAll(Colors.Red)
music.playSoundUntilDone(music.sounds(Sounds.PowerDown))
}
pins.A7.digitalWrite(false)
})
light.setAll(0xffffff)
Health = 1
Hits = 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment