Jody
Created December 5, 2022

Final Project Mushroom Dance

Enjoy an interactive sculpture that lets you dance the night away just like mushrooms do!

5
Final Project Mushroom Dance

Things used in this project

Hardware components

Circuit Playground Express
Adafruit Circuit Playground Express
×1
Alligator Clips
Alligator Clips
×1
USB-A to Mini-USB Cable
USB-A to Mini-USB Cable
×1

Software apps and online services

MakeCode
Microsoft MakeCode

Story

Read more

Code

Mushroom Dance Game

JavaScript
This is the code I made with the help of school knowledge and Makecode Arcade Tutorials
controller.up.onEvent(ControllerButtonEvent.Pressed, function () {
    Mushroom_Dancer.setPosition(60, 100)
})
controller.left.onEvent(ControllerButtonEvent.Pressed, function () {
    Mushroom_Dancer.setPosition(30, 100)
})
info.onScore(10, function () {
    game.over(true, effects.confetti)
})
controller.right.onEvent(ControllerButtonEvent.Pressed, function () {
    Mushroom_Dancer.setPosition(130, 100)
})
sprites.onOverlap(SpriteKind.Player, SpriteKind.Projectile, function (sprite, otherSprite) {
    otherSprite.destroy(effects.disintegrate, 100)
    music.setVolume(10)
    info.changeScoreBy(1)
})
controller.down.onEvent(ControllerButtonEvent.Pressed, function () {
    Mushroom_Dancer.setPosition(100, 100)
})
info.onLifeZero(function () {
    game.over(false, effects.melt)
})
scene.onHitWall(SpriteKind.Projectile, function (sprite, location) {
    sprite.destroy(effects.fire, 100)
    info.changeLifeBy(-1)
})
let Right: Sprite = null
let Down: Sprite = null
let Up: Sprite = null
let Left: Sprite = null
let Lane = 0
let Mushroom_Dancer: Sprite = null
tiles.setCurrentTilemap(tilemap`Main Level`)
effects.starField.startScreenEffect()
Mushroom_Dancer = sprites.create(img`
    . . . . . . b b b b . . . . . . 
    . . . . b b 3 3 3 3 b b . . . . 
    . . . c b 3 3 3 3 1 1 b c . . . 
    . . c b 3 3 3 3 3 1 1 1 b c . . 
    . c c 1 1 1 3 3 3 3 1 1 3 c c . 
    c c d 1 1 1 3 3 3 3 3 3 3 b c c 
    c b d d 1 3 3 3 3 3 1 1 1 b b c 
    c b b b 3 3 1 1 3 3 1 1 d d b c 
    c b b b b d d 1 1 3 b d d d b c 
    . c b b b b d d b b b b b b c . 
    . . c c b b b b b b b b c c . . 
    . . . . c c c c c c c c . . . . 
    . . . . . . b 1 1 b . . . . . . 
    . . . . . . b 1 1 b b . . . . . 
    . . . . . b d d 1 1 b . . . . . 
    . . . . . b b b b b b . . . . . 
    `, SpriteKind.Player)
Mushroom_Dancer.setPosition(80, 100)
let Speed = 40
info.setScore(0)
info.setLife(3)
game.onUpdateInterval(2000, function () {
    Lane = randint(1, 4)
    if (Lane == 1) {
        Left = sprites.create(assets.image`Left Arrow`, SpriteKind.Projectile)
        Left.setVelocity(0, Speed)
        Left.setPosition(30, 8)
    } else if (Lane == 2) {
        Up = sprites.create(assets.image`Up Mushroom`, SpriteKind.Projectile)
        Up.setVelocity(0, Speed)
        Up.setPosition(60, 8)
    } else if (Lane == 3) {
        Down = sprites.create(assets.image`Down Mushroom`, SpriteKind.Projectile)
        Down.setVelocity(0, Speed)
        Down.setPosition(100, 8)
    } else {
        Right = sprites.create(assets.image`Right Mushroom`, SpriteKind.Projectile)
        Right.setVelocity(0, Speed)
        Right.setPosition(130, 8)
    }
})

Mushroom Controller

JavaScript
This is the simple code I used to code the strange controller
input.touchA1.onEvent(ButtonEvent.Click, function () {
    keyboard.type("w")
})
input.touchA3.onEvent(ButtonEvent.Click, function () {
    keyboard.type("a")
})
input.touchA4.onEvent(ButtonEvent.Click, function () {
    keyboard.type("d")
})
input.touchA2.onEvent(ButtonEvent.Click, function () {
    keyboard.type("s")
})

Credits

Jody
4 projects • 0 followers
Contact

Comments

Please log in or sign up to comment.