nlpke
Published © CC BY-SA

Calliope Mini - Fragespiel per Funk

Ein Funk-basiertes Frage-Antwort Spiel mit dem Calliope Mini.

IntermediateFull instructions provided30 minutes4,697
Calliope Mini - Fragespiel per Funk

Things used in this project

Hardware components

Calliope mini
Calliope mini
×1

Story

Read more

Code

GameMaster Code

JavaScript
Diesen Code in den Javascript Bereich (oben auswählbar) vom PXT-Editor kopieren und wieder in den Block-Modus wechseln
input.onButtonPressed(Button.A, () => {
    basic.showLeds(`
        # # # # #
        # . . . #
        # . . . #
        # . . . #
        # # # # #
        `)
    music.playTone(Note.C, music.beat(BeatFraction.Whole))
    radio.sendString("A")
    basic.showLeds(`
        . . . . .
        . # # # .
        . # # # .
        . # # # .
        . . . . .
        `)
})
input.onButtonPressed(Button.B, () => {
    basic.showLeds(`
        # # # # #
        # . . . #
        # . . . #
        # . . . #
        # # # # #
        `)
    music.playTone(Note.C, music.beat(BeatFraction.Whole))
    radio.sendString("B")
    basic.showLeds(`
        . . . . .
        . # # # .
        . # # # .
        . # # # .
        . . . . .
        `)
})
basic.showLeds(`
    . . . . .
    . # # # .
    . # # # .
    . # # # .
    . . . . .
    `)
radio.setGroup(15)
radio.setTransmitPower(7)

GamePlayer Code

JavaScript
Anleitung zum Einfügen in den PXT-Editor: Siehe GameMaster Code
let Bereit = 0
let Richtige_Antwort = ""
input.onButtonPressed(Button.A, () => {
    if (Bereit == 1) {
        if (Richtige_Antwort == "A") {
            basic.showLeds(`
                . . . . .
                . . . . #
                . # . # .
                . . # . .
                . . . . .
                `)
            basic.setLedColor(Colors.Green)
        } else {
            basic.showLeds(`
                # . . . #
                . # . # .
                . . # . .
                . # . # .
                # . . . #
                `)
            basic.setLedColor(Colors.Red)
        }
        Bereit = 0
    }
})
input.onButtonPressed(Button.B, () => {
    if (Bereit == 1) {
        if (Richtige_Antwort == "B") {
            basic.showLeds(`
                . . . . .
                . . . . #
                . # . # .
                . . # . .
                . . . . .
                `)
            basic.setLedColor(Colors.Green)
        } else {
            basic.showLeds(`
                # . . . #
                . # . # .
                . . # . .
                . # . # .
                # . . . #
                `)
            basic.setLedColor(Colors.Red)
        }
        Bereit = 0
    }
})
radio.onDataPacketReceived(({receivedString}) => {
    Richtige_Antwort = receivedString
    basic.setLedColor(Colors.Blue)
    music.playTone(Note.C, music.beat(BeatFraction.Eighth))
    music.playTone(Note.F, music.beat(BeatFraction.Eighth))
    Bereit = 1
    basic.showLeds(`
        . # # # .
        # . . . #
        # . . . #
        # . . . #
        . # # # .
        `)
})
radio.setGroup(15)
radio.setTransmitPower(10)
basic.setLedColor(Colors.Yellow)

Credits

nlpke

nlpke

3 projects • 6 followers
Hi!

Comments