|
| 1 | +/* |
| 2 | +@title: Legally Distinct Yellow Creature Collects Bananas |
| 3 | +@author: DogeJr |
| 4 | +@tags: [] |
| 5 | +@addedOn: 2025-01-22 |
| 6 | +*/ |
| 7 | + |
| 8 | +//Starting the game |
| 9 | + |
| 10 | +const player = "p" |
| 11 | +const banana = "w" |
| 12 | +const wall = "i" |
| 13 | + |
| 14 | + |
| 15 | +const health4 = "9" |
| 16 | +const health35 = "8" |
| 17 | +const health3 = "7" |
| 18 | +const health25 = "6" |
| 19 | +const health2 = "5" |
| 20 | +const health15 = "4" |
| 21 | +const health1 = "3" |
| 22 | +const health05 = "2" |
| 23 | +const health0 = "1" |
| 24 | + |
| 25 | + |
| 26 | + |
| 27 | +//Making da map |
| 28 | +setLegend( |
| 29 | + [player, bitmap` |
| 30 | +.......666...... |
| 31 | +.....666666..... |
| 32 | +...666611666.... |
| 33 | +...6661661666... |
| 34 | +...0016006100... |
| 35 | +...0016006100... |
| 36 | +...6661661666... |
| 37 | +...6666116666... |
| 38 | +...6666666666... |
| 39 | +...5666666665... |
| 40 | +..665666666566.. |
| 41 | +.66.55555555.66. |
| 42 | +.66.55555555.66. |
| 43 | +.66.55555555.66. |
| 44 | +....55555555.... |
| 45 | +....00....00....`], |
| 46 | + [banana, bitmap` |
| 47 | +............000. |
| 48 | +...........00C0. |
| 49 | +...........0CC00 |
| 50 | +...........06660 |
| 51 | +...........06660 |
| 52 | +..........006660 |
| 53 | +.........0066600 |
| 54 | +.........066660. |
| 55 | +.......00066660. |
| 56 | +......006666600. |
| 57 | +....0006666600.. |
| 58 | +0000066666600... |
| 59 | +066666666000.... |
| 60 | +0066666000...... |
| 61 | +.0000000........ |
| 62 | +................`], |
| 63 | + [wall, bitmap` |
| 64 | +................ |
| 65 | +................ |
| 66 | +................ |
| 67 | +................ |
| 68 | +................ |
| 69 | +................ |
| 70 | +................ |
| 71 | +................ |
| 72 | +................ |
| 73 | +................ |
| 74 | +................ |
| 75 | +................ |
| 76 | +................ |
| 77 | +................ |
| 78 | +................ |
| 79 | +................`], |
| 80 | + [health4, bitmap` |
| 81 | +.00.00...00.00.. |
| 82 | +0330330.0330330. |
| 83 | +0333330.0333330. |
| 84 | +0333330.0333330. |
| 85 | +.03330...03330.. |
| 86 | +..030.....030... |
| 87 | +...0.......0.... |
| 88 | +................ |
| 89 | +................ |
| 90 | +.00.00...00.00.. |
| 91 | +0330330.0330330. |
| 92 | +0333330.0333330. |
| 93 | +0333330.0333330. |
| 94 | +.03330...03330.. |
| 95 | +..030.....030... |
| 96 | +...0.......0....`], |
| 97 | + [health35, bitmap ` |
| 98 | +.00.00...00.00.. |
| 99 | +0330330.0330..0. |
| 100 | +0333330.0333..0. |
| 101 | +0333330.0333..0. |
| 102 | +.03330...03..0.. |
| 103 | +..030.....0.0... |
| 104 | +...0.......0.... |
| 105 | +................ |
| 106 | +................ |
| 107 | +.00.00...00.00.. |
| 108 | +0330330.0330330. |
| 109 | +0333330.0333330. |
| 110 | +0333330.0333330. |
| 111 | +.03330...03330.. |
| 112 | +..030.....030... |
| 113 | +...0.......0....`], |
| 114 | + [health3, bitmap ` |
| 115 | +.00.00...00.00.. |
| 116 | +0330330.0..0..0. |
| 117 | +0333330.0.....0. |
| 118 | +0333330.0.....0. |
| 119 | +.03330...0...0.. |
| 120 | +..030.....0.0... |
| 121 | +...0.......0.... |
| 122 | +................ |
| 123 | +................ |
| 124 | +.00.00...00.00.. |
| 125 | +0330330.0330330. |
| 126 | +0333330.0333330. |
| 127 | +0333330.0333330. |
| 128 | +.03330...03330.. |
| 129 | +..030.....030... |
| 130 | +...0.......0....`], |
| 131 | + [health25, bitmap ` |
| 132 | +.00.00...00.00.. |
| 133 | +0330..0.0..0..0. |
| 134 | +0333..0.0.....0. |
| 135 | +0333..0.0.....0. |
| 136 | +.03..0...0...0.. |
| 137 | +..0.0.....0.0... |
| 138 | +...0.......0.... |
| 139 | +................ |
| 140 | +................ |
| 141 | +.00.00...00.00.. |
| 142 | +0330330.0330330. |
| 143 | +0333330.0333330. |
| 144 | +0333330.0333330. |
| 145 | +.03330...03330.. |
| 146 | +..030.....030... |
| 147 | +...0.......0....`], |
| 148 | + [health2, bitmap ` |
| 149 | +.00.00...00.00.. |
| 150 | +0..0..0.0..0..0. |
| 151 | +0.....0.0.....0. |
| 152 | +0.....0.0.....0. |
| 153 | +.0...0...0...0.. |
| 154 | +..0.0.....0.0... |
| 155 | +...0.......0.... |
| 156 | +................ |
| 157 | +................ |
| 158 | +.00.00...00.00.. |
| 159 | +0330330.0330330. |
| 160 | +0333330.0333330. |
| 161 | +0333330.0333330. |
| 162 | +.03330...03330.. |
| 163 | +..030.....030... |
| 164 | +...0.......0....`], |
| 165 | + [health15, bitmap ` |
| 166 | +.00.00...00.00.. |
| 167 | +0..0..0.0..0..0. |
| 168 | +0.....0.0.....0. |
| 169 | +0.....0.0.....0. |
| 170 | +.0...0...0...0.. |
| 171 | +..0.0.....0.0... |
| 172 | +...0.......0.... |
| 173 | +................ |
| 174 | +................ |
| 175 | +.00.00...00.00.. |
| 176 | +0330330.0330..0. |
| 177 | +0333330.0333..0. |
| 178 | +0333330.0333..0. |
| 179 | +.03330...03..0.. |
| 180 | +..030.....0.0... |
| 181 | +...0.......0....`], |
| 182 | + [health1, bitmap ` |
| 183 | +.00.00...00.00.. |
| 184 | +0..0..0.0..0..0. |
| 185 | +0.....0.0.....0. |
| 186 | +0.....0.0.....0. |
| 187 | +.0...0...0...0.. |
| 188 | +..0.0.....0.0... |
| 189 | +...0.......0.... |
| 190 | +................ |
| 191 | +................ |
| 192 | +.00.00...00.00.. |
| 193 | +0330330.0..0..0. |
| 194 | +0333330.0.....0. |
| 195 | +0333330.0.....0. |
| 196 | +.03330...0...0.. |
| 197 | +..030.....0.0... |
| 198 | +...0.......0....`], |
| 199 | + [health05, bitmap ` |
| 200 | +.00.00...00.00.. |
| 201 | +0..0..0.0..0..0. |
| 202 | +0.....0.0.....0. |
| 203 | +0.....0.0.....0. |
| 204 | +.0...0...0...0.. |
| 205 | +..0.0.....0.0... |
| 206 | +...0.......0.... |
| 207 | +................ |
| 208 | +................ |
| 209 | +.00.00...00.00.. |
| 210 | +0330..0.0..0..0. |
| 211 | +0333..0.0.....0. |
| 212 | +0333..0.0.....0. |
| 213 | +.03..0...0...0.. |
| 214 | +..0.0.....0.0... |
| 215 | +...0.......0....`], |
| 216 | + [health0, bitmap ` |
| 217 | +.00.00...00.00.. |
| 218 | +0..0..0.0..0..0. |
| 219 | +0.....0.0.....0. |
| 220 | +0.....0.0.....0. |
| 221 | +.0...0...0...0.. |
| 222 | +..0.0.....0.0... |
| 223 | +...0.......0.... |
| 224 | +................ |
| 225 | +................ |
| 226 | +.00.00...00.00.. |
| 227 | +0..0..0.0..0..0. |
| 228 | +0.....0.0.....0. |
| 229 | +0.....0.0.....0. |
| 230 | +.0...0...0...0.. |
| 231 | +..0.0.....0.0... |
| 232 | +...0.......0....`], |
| 233 | +) |
| 234 | +setSolids([player, wall,]) |
| 235 | +let level = 0 |
| 236 | +const levels = [ |
| 237 | + map` |
| 238 | +iiiiiiii |
| 239 | +.p...w.. |
| 240 | +........ |
| 241 | +........`, |
| 242 | + map ` |
| 243 | +........ |
| 244 | +........ |
| 245 | +........ |
| 246 | +........`, |
| 247 | +] |
| 248 | + |
| 249 | + |
| 250 | +setMap(levels[level]) |
| 251 | +setPushables({ |
| 252 | + [player]: [] |
| 253 | +}) |
| 254 | + |
| 255 | +const ding = tune` |
| 256 | +101.69491525423729: B4/101.69491525423729, |
| 257 | +101.69491525423729: C5/101.69491525423729, |
| 258 | +3050.8474576271187` |
| 259 | + |
| 260 | +//Set points to 0 |
| 261 | +var Points = 0 |
| 262 | +var health = 9 |
| 263 | +var difficulty = 800 |
| 264 | +var hLoop = 0; |
| 265 | + |
| 266 | +function placeRandomSprite(spriteType) { |
| 267 | + const emptyTiles = []; |
| 268 | + const mapWidth = width(); |
| 269 | + const mapHeight = height(); |
| 270 | + for (let x = 0; x < mapWidth; x++) { |
| 271 | + for (let y = 0; y < mapHeight; y++) { |
| 272 | + if (getTile(x, y).length === 0) { |
| 273 | + emptyTiles.push({ x, y }); |
| 274 | + } |
| 275 | + } |
| 276 | + } |
| 277 | + if (emptyTiles.length === 0) { |
| 278 | + console.log("no empty tiles") |
| 279 | + return; |
| 280 | + } |
| 281 | + const randomTile = emptyTiles[Math.floor(Math.random() * emptyTiles.length)]; |
| 282 | + addSprite(randomTile.x, randomTile.y, spriteType); |
| 283 | +} |
| 284 | + |
| 285 | +function updatePoints() { |
| 286 | + clearText() |
| 287 | + addText("Bananas: " + Points, { |
| 288 | + x: 8, |
| 289 | + y: 4, |
| 290 | + color: color`4`, |
| 291 | + }) |
| 292 | +} |
| 293 | + |
| 294 | +function updateHealth() { |
| 295 | + if (health > 0) { |
| 296 | + clearTile(0, 0) |
| 297 | + addSprite(0, 0, health)} |
| 298 | + addSprite(0, 0, wall)} |
| 299 | + |
| 300 | + |
| 301 | + |
| 302 | + |
| 303 | +function healthLoop() { |
| 304 | + if (health > 0) { |
| 305 | + setTimeout(function(){ |
| 306 | + health-- |
| 307 | + updateHealth(); |
| 308 | + difficulty = difficulty - 5 |
| 309 | + if (hLoop < 9999999) { |
| 310 | + healthLoop(); |
| 311 | + } |
| 312 | + }, difficulty) |
| 313 | + } |
| 314 | + else { |
| 315 | + setMap(levels[1]) |
| 316 | + clearText() |
| 317 | + addText("you dided!11!1!", { |
| 318 | + x: 3, |
| 319 | + y: 7, |
| 320 | + color: color`0`,}) |
| 321 | + }; |
| 322 | + } |
| 323 | + |
| 324 | + |
| 325 | +//inputs |
| 326 | +onInput("w", () => { |
| 327 | + getFirst(player).y -= 1; |
| 328 | +}); |
| 329 | +onInput("a", () => { |
| 330 | + getFirst(player).x -= 1; |
| 331 | +}); |
| 332 | +onInput("s", () => { |
| 333 | + getFirst(player).y += 1; |
| 334 | +}); |
| 335 | +onInput("d", () => { |
| 336 | + getFirst(player).x += 1; |
| 337 | +}); |
| 338 | + |
| 339 | +afterInput(() => { |
| 340 | + if (tilesWith(banana, player, ).length >= 1) { |
| 341 | + getFirst(banana).remove(); |
| 342 | + Points = Points + 1 |
| 343 | + if (health > 0) { |
| 344 | + if ((health + 2) > 9) { |
| 345 | + health = health + (9 - health) |
| 346 | + } else { |
| 347 | + health = health + 2} |
| 348 | + updatePoints() |
| 349 | + updateHealth() |
| 350 | + placeRandomSprite(banana) |
| 351 | + playTune(ding)} |
| 352 | + } |
| 353 | +}) |
| 354 | + |
| 355 | +setMap(levels[0]) |
| 356 | +updatePoints() |
| 357 | +updateHealth() |
| 358 | +healthLoop() |
| 359 | +console.log("startup initiated") |
0 commit comments