SHOW:
|
|
- or go back to the newest paste.
| 1 | let score = 0 | |
| 2 | let playingState = 0 | |
| 3 | let playerY = 2 | |
| 4 | let objectX = 4 | |
| 5 | let objectY = Math.randomRange(0, 4) | |
| 6 | let objectX1 = 4 | |
| 7 | let objectY1 = Math.randomRange(0, 4) | |
| 8 | let objectX2 = 4 | |
| 9 | let objectY2 = Math.randomRange(0, 4) | |
| 10 | basic.forever(function () {
| |
| 11 | if (playingState == 0) {
| |
| 12 | basic.showString("A")
| |
| 13 | if (input.buttonIsPressed(Button.A) && playingState == 0) {
| |
| 14 | images.createBigImage(` | |
| 15 | # # . . . . . . . . | |
| 16 | . # # . . . . . . . | |
| 17 | . . # # . . . . . . | |
| 18 | . . . # # . . . . . | |
| 19 | . . . . # # . . . . | |
| 20 | `).scrollImage(1, 200) | |
| 21 | basic.pause(500) | |
| 22 | playingState = 1 | |
| 23 | } | |
| 24 | basic.clearScreen() | |
| 25 | } | |
| 26 | while (playingState == 1) {
| |
| 27 | led.plot(0, playerY) | |
| 28 | led.plot(objectX, objectY) | |
| 29 | if (score > 9) {
| |
| 30 | led.plot(objectX1, objectY1) | |
| 31 | } | |
| 32 | if (score > 24) {
| |
| 33 | led.plot(objectX2, objectY2) | |
| 34 | } | |
| 35 | if (playingState == 1 && input.buttonIsPressed(Button.A)) {
| |
| 36 | playerY += -1 | |
| 37 | } | |
| 38 | if (playingState == 1 && input.buttonIsPressed(Button.B)) {
| |
| 39 | playerY += 1 | |
| 40 | } | |
| 41 | if (objectX < 0) {
| |
| 42 | objectX = 5 | |
| 43 | objectX1 = 5 | |
| 44 | objectX2 = 5 | |
| 45 | score += 1 | |
| 46 | if (score > 9) {
| |
| 47 | score = score + 2 | |
| 48 | } | |
| 49 | objectY = Math.randomRange(0, 4) | |
| 50 | music.playTone(262, music.beat(BeatFraction.Quarter)) | |
| 51 | } | |
| 52 | if (playerY < 0) {
| |
| 53 | playerY = 0 | |
| 54 | } | |
| 55 | if (playerY > 4) {
| |
| 56 | playerY = 4 | |
| 57 | } | |
| 58 | if (objectX == 0 && playerY == objectY) {
| |
| 59 | playingState = 2 | |
| 60 | } | |
| 61 | if (score > 9 && objectX1 == 0 && playerY == objectY1) {
| |
| 62 | playingState = 2 | |
| 63 | } | |
| 64 | if (score > 24 && objectX2 == 0 && playerY == objectY2) {
| |
| 65 | playingState = 2 | |
| 66 | } | |
| 67 | objectX += -1 | |
| 68 | if (score > 9) {
| |
| 69 | objectX1 += -1 | |
| 70 | } | |
| 71 | if (score > 24) {
| |
| 72 | objectX2 += -1 | |
| 73 | } | |
| 74 | basic.pause(250) | |
| 75 | basic.clearScreen() | |
| 76 | } | |
| 77 | if (playingState == 2) {
| |
| 78 | images.createBigImage(` | |
| 79 | # # . . . . . . . . | |
| 80 | . # # . . . . . . . | |
| 81 | . . # # . . . . . . | |
| 82 | . . . # # . . . . . | |
| 83 | . . . . # # . . . . | |
| 84 | `).scrollImage(1, 200) | |
| 85 | music.playTone(294, music.beat(BeatFraction.Eighth)) | |
| 86 | music.rest(music.beat(BeatFraction.Sixteenth)) | |
| 87 | music.playTone(294, music.beat(BeatFraction.Eighth)) | |
| 88 | music.rest(music.beat(BeatFraction.Sixteenth)) | |
| 89 | music.playTone(587, music.beat(BeatFraction.Eighth)) | |
| 90 | music.rest(music.beat(BeatFraction.Quarter)) | |
| 91 | music.playTone(440, music.beat(BeatFraction.Eighth)) | |
| 92 | music.rest(music.beat(BeatFraction.Half)) | |
| 93 | music.playTone(415, music.beat(BeatFraction.Eighth)) | |
| 94 | music.rest(music.beat(BeatFraction.Quarter)) | |
| 95 | music.playTone(392, music.beat(BeatFraction.Eighth)) | |
| 96 | music.rest(music.beat(BeatFraction.Quarter)) | |
| 97 | music.playTone(349, music.beat(BeatFraction.Quarter)) | |
| 98 | music.rest(music.beat(BeatFraction.Sixteenth)) | |
| 99 | music.playTone(294, music.beat(BeatFraction.Eighth)) | |
| 100 | music.rest(music.beat(BeatFraction.Sixteenth)) | |
| 101 | music.playTone(349, music.beat(BeatFraction.Eighth)) | |
| 102 | music.rest(music.beat(BeatFraction.Sixteenth)) | |
| 103 | music.playTone(392, music.beat(BeatFraction.Eighth)) | |
| 104 | music.playTone(262, music.beat(BeatFraction.Eighth)) | |
| 105 | music.rest(music.beat(BeatFraction.Sixteenth)) | |
| 106 | music.playTone(262, music.beat(BeatFraction.Eighth)) | |
| 107 | music.rest(music.beat(BeatFraction.Sixteenth)) | |
| 108 | music.playTone(587, music.beat(BeatFraction.Eighth)) | |
| 109 | music.rest(music.beat(BeatFraction.Quarter)) | |
| 110 | music.playTone(440, music.beat(BeatFraction.Eighth)) | |
| 111 | music.rest(music.beat(BeatFraction.Half)) | |
| 112 | music.playTone(415, music.beat(BeatFraction.Eighth)) | |
| 113 | music.rest(music.beat(BeatFraction.Quarter)) | |
| 114 | music.playTone(392, music.beat(BeatFraction.Eighth)) | |
| 115 | music.rest(music.beat(BeatFraction.Quarter)) | |
| 116 | music.playTone(349, music.beat(BeatFraction.Quarter)) | |
| 117 | music.rest(music.beat(BeatFraction.Sixteenth)) | |
| 118 | music.playTone(294, music.beat(BeatFraction.Eighth)) | |
| 119 | music.rest(music.beat(BeatFraction.Sixteenth)) | |
| 120 | music.playTone(349, music.beat(BeatFraction.Eighth)) | |
| 121 | music.rest(music.beat(BeatFraction.Sixteenth)) | |
| 122 | music.playTone(392, music.beat(BeatFraction.Eighth)) | |
| 123 | music.playTone(247, music.beat(BeatFraction.Eighth)) | |
| 124 | music.rest(music.beat(BeatFraction.Sixteenth)) | |
| 125 | music.playTone(247, music.beat(BeatFraction.Eighth)) | |
| 126 | music.rest(music.beat(BeatFraction.Sixteenth)) | |
| 127 | music.playTone(587, music.beat(BeatFraction.Eighth)) | |
| 128 | music.rest(music.beat(BeatFraction.Quarter)) | |
| 129 | music.playTone(440, music.beat(BeatFraction.Eighth)) | |
| 130 | music.rest(music.beat(BeatFraction.Half)) | |
| 131 | music.playTone(415, music.beat(BeatFraction.Eighth)) | |
| 132 | music.rest(music.beat(BeatFraction.Quarter)) | |
| 133 | music.playTone(392, music.beat(BeatFraction.Eighth)) | |
| 134 | music.rest(music.beat(BeatFraction.Quarter)) | |
| 135 | music.playTone(349, music.beat(BeatFraction.Quarter)) | |
| 136 | music.rest(music.beat(BeatFraction.Sixteenth)) | |
| 137 | music.playTone(294, music.beat(BeatFraction.Eighth)) | |
| 138 | music.rest(music.beat(BeatFraction.Sixteenth)) | |
| 139 | music.playTone(349, music.beat(BeatFraction.Eighth)) | |
| 140 | music.rest(music.beat(BeatFraction.Sixteenth)) | |
| 141 | music.playTone(392, music.beat(BeatFraction.Eighth)) | |
| 142 | music.playTone(233, music.beat(BeatFraction.Eighth)) | |
| 143 | music.rest(music.beat(BeatFraction.Sixteenth)) | |
| 144 | music.playTone(233, music.beat(BeatFraction.Eighth)) | |
| 145 | music.rest(music.beat(BeatFraction.Sixteenth)) | |
| 146 | music.playTone(587, music.beat(BeatFraction.Eighth)) | |
| 147 | music.rest(music.beat(BeatFraction.Quarter)) | |
| 148 | music.playTone(440, music.beat(BeatFraction.Eighth)) | |
| 149 | music.rest(music.beat(BeatFraction.Half)) | |
| 150 | music.playTone(415, music.beat(BeatFraction.Eighth)) | |
| 151 | music.rest(music.beat(BeatFraction.Quarter)) | |
| 152 | music.playTone(392, music.beat(BeatFraction.Eighth)) | |
| 153 | music.rest(music.beat(BeatFraction.Quarter)) | |
| 154 | music.playTone(349, music.beat(BeatFraction.Quarter)) | |
| 155 | music.rest(music.beat(BeatFraction.Sixteenth)) | |
| 156 | music.playTone(294, music.beat(BeatFraction.Eighth)) | |
| 157 | music.rest(music.beat(BeatFraction.Sixteenth)) | |
| 158 | music.playTone(349, music.beat(BeatFraction.Eighth)) | |
| 159 | music.rest(music.beat(BeatFraction.Sixteenth)) | |
| 160 | music.playTone(392, music.beat(BeatFraction.Eighth)) | |
| 161 | basic.showNumber(score) | |
| 162 | if (input.buttonIsPressed(Button.A)) {
| |
| 163 | playingState = 0 | |
| 164 | score = 0 | |
| 165 | } | |
| 166 | } | |
| 167 | }) |