SHOW:
|
|
- or go back to the newest paste.
| 1 | let ticks = 0 | |
| 2 | let emptyObstacleY = 0 | |
| 3 | let obstacles: game.LedSprite[] = [] | |
| 4 | let index = 0 | |
| 5 | let bird: game.LedSprite = null | |
| 6 | input.onButtonPressed(Button.A, () => {
| |
| 7 | bird.change(LedSpriteProperty.Y, -1) | |
| 8 | }) | |
| 9 | input.onButtonPressed(Button.B, () => {
| |
| 10 | bird.change(LedSpriteProperty.Y, 1) | |
| 11 | }) | |
| 12 | index = 0 | |
| 13 | obstacles = [] | |
| 14 | bird = game.createSprite(0, 2) | |
| 15 | bird.set(LedSpriteProperty.Blink, 300) | |
| 16 | basic.forever(() => {
| |
| 17 | while (obstacles.length > 0 && obstacles[0].get(LedSpriteProperty.X) == 0) {
| |
| 18 | obstacles.removeAt(0).delete() | |
| 19 | } | |
| 20 | for (let obstacle2 of obstacles) {
| |
| 21 | obstacle2.change(LedSpriteProperty.X, -1) | |
| 22 | } | |
| 23 | if (ticks % 3 == 0) {
| |
| 24 | emptyObstacleY = Math.randomRange(0, 4) | |
| 25 | for (let index2 = 0; index2 <= 4; index2++) {
| |
| 26 | if (index2 != emptyObstacleY) {
| |
| 27 | obstacles.push(game.createSprite(4, index2)) | |
| 28 | } | |
| 29 | } | |
| 30 | } | |
| 31 | for (let obstacle3 of obstacles) {
| |
| 32 | if (obstacle3.get(LedSpriteProperty.X) == bird.get(LedSpriteProperty.X) && obstacle3.get(LedSpriteProperty.Y) == bird.get(LedSpriteProperty.Y)) {
| |
| 33 | game.gameOver() | |
| 34 | } | |
| 35 | } | |
| 36 | ticks += 1 | |
| 37 | basic.pause(1000) | |
| 38 | }) |