Ali
Published © CC BY-NC-SA

Calliope-Minispiel

Ein Minispiel, wo fallende Blöcke gesammelt werden müssen.

BeginnerFull instructions provided1 hour427
Calliope-Minispiel

Things used in this project

Hardware components

Calliope mini
Calliope mini
×1

Story

Read more

Code

Minispiel - mit LED

JavaScript
let block_y = 0
let block_x = 0
let spieler_x = 0
input.onButtonPressed(Button.A, () => {
    spieler_x += -1
    if (spieler_x <= 0) {
        spieler_x = 0
    }
})
input.onButtonPressed(Button.B, () => {
    spieler_x += 1
    if (spieler_x >= 4) {
        spieler_x = 4
    }
})
basic.forever(() => {
    basic.clearScreen()
    led.plot(spieler_x, 4)
    led.plot(block_x, block_y)
})
block_x = 0
block_y = -1
while (true) {
    basic.setLedColor(basic.rgbw(
        0,
        0,
        0,
        0
    ))
    block_x = Math.random(5)
    for (let i = 0; i <= 4; i++) {
        basic.pause(500)
        block_y += 1
    }
    if (spieler_x == block_x) {
        basic.setLedColor(Colors.Green)
    } else {
        basic.setLedColor(Colors.Red)
    }
    block_y = -1
    basic.pause(1000)
}

Minispiel - ohne alles

JavaScript
let block_y = 0
let block_x = 0
let spieler_x = 0
input.onButtonPressed(Button.A, () => {
    spieler_x += -1
    if (spieler_x <= 0) {
        spieler_x = 0
    }
})
input.onButtonPressed(Button.B, () => {
    spieler_x += 1
    if (spieler_x >= 4) {
        spieler_x = 4
    }
})
basic.forever(() => {
    basic.clearScreen()
    led.plot(spieler_x, 4)
    led.plot(block_x, block_y)
})
block_x = 0
block_y = -1
while (true) {
    block_x = Math.random(5)
    for (let i = 0; i <= 4; i++) {
        basic.pause(500)
        block_y += 1
    }
    block_y = -1
    basic.pause(1000)
}

Minispiel - mit LED und Ton

JavaScript
let block_y = 0
let spieler_x = 0
let block_x = 0
input.onButtonPressed(Button.A, () => {
    music.playTone(262, music.beat(BeatFraction.Eighth))
    spieler_x += -1
    if (spieler_x <= 0) {
        spieler_x = 0
    }
})
input.onButtonPressed(Button.B, () => {
    music.playTone(262, music.beat(BeatFraction.Eighth))
    spieler_x += 1
    if (spieler_x >= 4) {
        spieler_x = 4
    }
})
basic.forever(() => {
    basic.clearScreen()
    led.plot(spieler_x, 4)
    led.plot(block_x, block_y)
})
block_x = 0
block_y = -1
while (true) {
    basic.setLedColor(basic.rgbw(
        0,
        0,
        0,
        0
    ))
    block_x = Math.random(5)
    for (let i = 0; i <= 4; i++) {
        basic.pause(500)
        block_y += 1
        music.playTone(262, music.beat(BeatFraction.Sixteenth))
    }
    block_y = -1
    if (block_x == spieler_x) {
        basic.setLedColor(Colors.Green)
        music.playTone(262, music.beat(BeatFraction.Sixteenth))
        music.playTone(262, music.beat(BeatFraction.Sixteenth))
    } else {
        basic.setLedColor(Colors.Red)
        music.playTone(262, music.beat(BeatFraction.Sixteenth))
        music.playTone(262, music.beat(BeatFraction.Sixteenth))
    }
    basic.pause(1000)
}

Minispiel - mit Ton

JavaScript
let block_y = 0
let spieler_x = 0
let block_x = 0
input.onButtonPressed(Button.A, () => {
    music.playTone(262, music.beat(BeatFraction.Eighth))
    spieler_x += -1
    if (spieler_x <= 0) {
        spieler_x = 0
    }
})
input.onButtonPressed(Button.B, () => {
    music.playTone(262, music.beat(BeatFraction.Eighth))
    spieler_x += 1
    if (spieler_x >= 4) {
        spieler_x = 4
    }
})
basic.forever(() => {
    basic.clearScreen()
    led.plot(spieler_x, 4)
    led.plot(block_x, block_y)
})
block_x = 0
block_y = -1
while (true) {
    block_x = Math.random(5)
    for (let i = 0; i <= 4; i++) {
        basic.pause(500)
        block_y += 1
        music.playTone(262, music.beat(BeatFraction.Sixteenth))
    }
    if (block_x == spieler_x) {
        music.playTone(262, music.beat(BeatFraction.Sixteenth))
        music.playTone(262, music.beat(BeatFraction.Sixteenth))
    } else {
        music.playTone(262, music.beat(BeatFraction.Sixteenth))
        music.playTone(262, music.beat(BeatFraction.Sixteenth))
    }
    block_y = -1
    basic.pause(1000)
}

Credits

Ali

Ali

1 project • 4 followers
My name is Ali, I'm a mathematics/computer science student and I develop games in my free time.

Comments