Michelle T
Published

Simon Says Bop It

Bop It Simon Says all together in a little box

IntermediateShowcase (no instructions)4 hours404
Simon Says Bop It

Things used in this project

Hardware components

Circuit Playground Express
Adafruit Circuit Playground Express
×1
Li-Polymer Battery, 150mAh
Li-Polymer Battery, 150mAh
×1
Alligator Clips
Alligator Clips
×2

Software apps and online services

MakeCode
Microsoft MakeCode

Hand tools and fabrication machines

Tissue Paper
Multi-Use Labels
Drill / Driver, Cordless
Drill / Driver, Cordless
Colored Rhinestones

Story

Read more

Code

circuitplayground-simonsaysbopit.uf2

Makefile
This code generates the whole game and controls the game as the player progresses
No preview (download only).

Simon Says Bop It JavaScript

JavaScript
The JavaScript version of the code. I had to move the parts for A1 and A7 into Tilt Up and Tilt Down functions.
function player (inputstart: number) {
    if (inputstart == arr[arraytaskvalue]) {
        if (inputstart == 0) {
            light.setAll(0x00ff00)
            music.playTone(175, music.beat(BeatFraction.Half))
            pause(500)
            light.clear()
        } else if (inputstart == 1) {
            light.setAll(0xffffff)
            music.playTone(294, music.beat(BeatFraction.Half))
            pause(500)
            light.clear()
        } else if (inputstart == 2) {
            light.setAll(0xff8000)
            music.playTone(494, music.beat(BeatFraction.Half))
            pause(500)
            light.clear()
        } else if (inputstart == 3) {
            light.setAll(0x0000ff)
            music.playTone(784, music.beat(BeatFraction.Half))
            pause(500)
            light.clear()
        }
        arraytaskvalue += 1
        // Win
        if (arraytaskvalue == arr.length) {
            win()
        }
    } else if (arraytaskvalue > arr.length) {
        wrongmissed()
    } else {
        wrongmissed()
    }
}
function rand () {
    arr.push(Math.randomRange(0, 3))
}
input.touchA1.onEvent(ButtonEvent.Click, function () {
	
})
input.onGesture(Gesture.TiltUp, function () {
    if (button == true) {
        onIsTrue()
    }
    button = false
})
function win () {
    music.jumpUp.play()
    light.showAnimation(light.rainbowAnimation, 2000)
    arraytaskvalue = 0
    arrayamount += 1
    on = true
    light.clear()
    pause(500)
    rand()
    gameStart()
}
input.touchA3.onEvent(ButtonEvent.Click, function () {
    gameStart()
})
function gameStart () {
    for (let gameStartIndex = 0; gameStartIndex <= arr.length; gameStartIndex++) {
        if (arr[gameStartIndex] == 0) {
            light.setAll(0x00ff00)
            music.playTone(196, music.beat(BeatFraction.Half))
            pause(500)
            light.clear()
        } else if (arr[gameStartIndex] == 1) {
            light.setAll(0xffffff)
            music.playTone(294, music.beat(BeatFraction.Half))
            pause(500)
            light.clear()
        } else if (arr[gameStartIndex] == 2) {
            light.setAll(0xff8000)
            music.playTone(440, music.beat(BeatFraction.Half))
            pause(500)
            light.clear()
        } else if (arr[gameStartIndex] == 3) {
            light.setAll(0x0000ff)
            music.playTone(659, music.beat(BeatFraction.Half))
            pause(500)
            light.clear()
        }
    }
}
input.onLoudSound(function () {
    if (start == true) {
        start = false
        player(0)
        start = true
    }
})
input.onGesture(Gesture.FaceDown, function () {
    if (start == true) {
        start = false
        player(2)
        start = true
    }
})
function onIsTrue () {
    arr = []
    if (on == true) {
        for (let i = 0; i < arrayamount; i++) {
            rand()
        }
        light.clear()
        gameStart()
        start = true
        on = false
    }
}
function wrongmissed () {
    // Lose
    if (lose == 3) {
        music.wawawawaa.play()
        light.showAnimation(light.theaterChaseAnimation, 2500)
        light.clear()
        light.showAnimation(light.cometAnimation, 3000)
        pause(2000)
        arrayamount = 4
        on = true
        lose = 0
        onIsTrue()
    } else {
        // 3 Tries after missed attempt
        lose += 1
        music.jumpDown.play()
        light.showAnimation(light.theaterChaseAnimation, 1500)
        light.clear()
        pause(500)
        gameStart()
    }
}
input.onGesture(Gesture.Shake, function () {
    if (start == true) {
        start = false
        player(1)
        start = true
    }
})
input.touchA7.onEvent(ButtonEvent.Click, function () {
	
})
input.onGesture(Gesture.TiltDown, function () {
    if (start == true) {
        start = false
        player(3)
        start = true
    }
})
let arr: number[] = []
let on = false
let start = false
let button = false
let lose = 0
let arraytaskvalue = 0
let arrayamount = 0
light.setBrightness(50)
music.setVolume(255)
light.showAnimationFrame(light.cometAnimation)
arrayamount = 4
arraytaskvalue = 0
lose = 0
button = true
start = false
on = true

Credits

Michelle T

Michelle T

4 projects • 0 followers

Comments