Hardware components | ||||||
| × | 1 |
Minispiel
Dieses Programm ist ein kleines Spiel. Mit den Tasten A und B steuern Sie den Spieler.
Ziel ist es, den Block zu fangen.
Es gibt 4 Arten:
-Ohne Alles
-Mit Ton
-Mit LED
-Mit Alles
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)
}
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)
}
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)
}
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)
}
Comments