diff --git a/games/lavender haze.js b/games/lavender haze.js new file mode 100644 index 0000000000..0777b7f422 --- /dev/null +++ b/games/lavender haze.js @@ -0,0 +1,372 @@ +// 🌿 Leafeon's Journey — Themed levels, better Leafeon sprite, no errors +// Controls: WASD to move, K to start / restart + +const player = "p" +const orb = "o" +const goal = "g" +const critter = "c" +const tree = "t" +const shrub = "s" +const vine = "v" +const rock = "r" +const flower = "f" +const water = "w" +const sky = "y" +const ground = "d" + +let level = 0 +let score = 0 + +// ---------- Legend (sprites) ---------- +setLegend( + [ player, bitmap` +................ +.......33....... +......32223..... +.....3222223.... +.....3222223.... +......32223..... +.......3333..... +......3..3...... +.....3....3..... +....33....33.... +....3......3.... +....3......3.... +....3......3.... +................ +................ +................` ], + [ orb, bitmap` +................ +................ +.......33....... +......3333...... +.....333333..... +....33333333.... +....33333333.... +.....333333..... +......3333...... +.......33....... +................ +................ +................ +................ +................ +................` ], + [ goal, bitmap` +................ +................ +.......22....... +......2222...... +.....222222..... +....22222222.... +...2222222222... +...2222222222... +....22222222.... +.....222222..... +......2222...... +.......22....... +................ +................ +................ +................` ], + [ critter, bitmap` +................ +......6666...... +.....677776..... +....67777776.... +....67777776.... +.....677776..... +......6666...... +......6..6...... +......6..6...... +......6..6...... +......6666...... +.......66....... +................ +................ +................ +................` ], + [ tree, bitmap` +................ +.....444444..... +....44444444.... +...4444444444... +...4444444444... +....44444444.... +.....444444..... +.......44....... +.......44....... +.......44....... +.......44....... +.......44....... +.......44....... +................ +................ +................` ], + [ shrub, bitmap` +................ +................ +.....333333..... +....33333333.... +...3333333333... +...3333333333... +....33333333.... +.....333333..... +......3333...... +................ +................ +................ +................ +................ +................ +................` ], + [ vine, bitmap` +.......77....... +.......77....... +.......77....... +.......77....... +.......77....... +.......77....... +.......77....... +.......77....... +.......77....... +.......77....... +.......77....... +.......77....... +.......77....... +.......77....... +.......77....... +.......77.......` ], + [ rock, bitmap` +................ +................ +....444444...... +...44444444..... +..4444444444.... +..4444444444.... +...44444444..... +....444444...... +................ +................ +................ +................ +................ +................ +................ +................` ], + [ flower, bitmap` +................ +.......3........ +......333....... +.......3........ +.....33333...... +......333....... +.......3........ +................ +................ +................ +................ +................ +................ +................ +................ +................` ], + [ water, bitmap` +2222222222222222 +2222222222222222 +2222222222222222 +2222222222222222 +2222222222222222 +2222222222222222 +2222222222222222 +2222222222222222 +2222222222222222 +2222222222222222 +2222222222222222 +2222222222222222 +2222222222222222 +2222222222222222 +2222222222222222 +2222222222222222` ], + [ sky, bitmap` +5555555555555555 +5555555555555555 +5555555555555555 +5555555555555555 +5555555555555555 +5555555555555555 +5555555555555555 +5555555555555555 +5555555555555555 +5555555555555555 +5555555555555555 +5555555555555555 +5555555555555555 +5555555555555555 +5555555555555555 +5555555555555555` ], + [ ground, bitmap` +3333333333333333 +3222222222222223 +3223333222333223 +3222222222222223 +3333333333333333 +3222222222222223 +3223333222333223 +3222222222222223 +3333333333333333 +3222222222222223 +3223333222333223 +3222222222222223 +3333333333333333 +3222222222222223 +3223333222333223 +3333333333333333` ] +) + +// ---------- Solids ---------- +setSolids([ tree, rock, shrub ]) + +// ---------- Levels ---------- +const levels = [ + // Intro (16 x 10) + map` +yyyyyyyyyyyyyyyy +ydddddddddddddyd +yd............dy +yd............dy +yd............dy +yd............dy +yd............dy +yd............dy +ydddddddddddddyd +yyyyyyyyyyyyyyyy`, + + // Level 1 (12 x 7) + map` +tttttttttttt +tp..f.o..fgt +t..tt..f...t +t.f..o...f.t +t..tt..o...t +to...c.....t +tttttttttttt`, + + // Level 2 (14 x 7) — fixed, all rows = 14 + map` +tttttttttttttt +tp..o..f..o.gtt +t..ttttwwww..t. +t..o..twwww..t. +t..c.tttww.o.t. +t...o..f..o..t. +tttttttttttttt.`, + + // Level 3 (16 x 7) — fixed, all rows = 16 + map` +tttttttttttttttt +tp.o.v..f..o..gt +t..ttttttt...ctt +t.o..t..o..vv.tt +t....tttttvv..tt +t..c...o....o.tt +tttttttttttttttt` +] + +// ---------- Music ---------- +const bgm = tune` +120: C4~120 + E4~120, +120: G4~120, +120: E4~120, +120: F4~120 + A4~120, +120: C5~120, +120: A4~120, +120: G4~120, +120: E4~120` +playTune(bgm, Infinity) + +// ---------- Boot / HUD ---------- +setMap(levels[level]) +showIntro() + +function showIntro() { + clearText() + addText("Leafeon's Journey", { x: 2, y: 1, color: color`3` }) + addText("WASD = move", { x: 3, y: 3, color: color`4` }) + addText("Collect orbs (o)", { x: 3, y: 4, color: color`2` }) + addText("Avoid critters (c)",{ x: 3, y: 5, color: color`6` }) + addText("Press K to start", { x: 3, y: 7, color: color`7` }) +} + +function drawHUD() { + if (level === 0) return + clearText() + addText("Score: " + score, { x: 0, y: 0, color: color`5` }) +} + +// ---------- Controls ---------- +onInput("w", () => movePlayer(0, -1)) +onInput("s", () => movePlayer(0, 1)) +onInput("a", () => movePlayer(-1, 0)) +onInput("d", () => movePlayer(1, 0)) +onInput("k", () => { + if (level === 0) { + level = 1 + score = 0 + setMap(levels[level]) + drawHUD() + } else { + setMap(levels[level]) + drawHUD() + } +}) + +// ---------- Helpers ---------- +function movePlayer(dx, dy) { + const p = getFirst(player) + if (!p) return + const nx = p.x + dx, ny = p.y + dy + if (getTile(nx, ny).some(s => s.type === tree || s.type === rock || s.type === shrub)) return + p.x = nx; p.y = ny + collectOrbAt(nx, ny) + drawHUD() +} +function collectOrbAt(x, y) { + for (const s of getTile(x, y)) if (s.type === orb) { + s.remove(); score += 10 + } +} + +// ---------- Critter AI ---------- +setInterval(() => { + for (const c of getAll(critter)) { + if (c.dir === undefined) c.dir = 1 + c.x += c.dir + if (c.x <= 0 || c.x >= width() - 1 || getTile(c.x, c.y).some(t => t.type === tree || t.type === rock || t.type === shrub)) { + c.x -= c.dir; c.dir *= -1 + } + } +}, 500) + +// ---------- Rules ---------- +afterInput(() => { + const p = getFirst(player) + if (!p) return + + if (tilesWith(player, critter).length || tilesWith(player, vine).length) { + addText("Ouch!", { x: 4, y: 4, color: color`6` }) + setTimeout(() => { setMap(levels[level]); drawHUD() }, 600) + return + } + + if (tilesWith(player, goal).length && tilesWith(orb).length === 0) { + score += 50; level++ + if (level < levels.length) { setMap(levels[level]); drawHUD() } + else { + clearText() + addText("You Win!", { x: 4, y: 3, color: color`3` }) + addText("Final Score: " + score, { x: 3, y: 5, color: color`5` }) + } + } +}) diff --git a/lavender haze (1).js b/lavender haze (1).js new file mode 100644 index 0000000000..d580c4d6f5 --- /dev/null +++ b/lavender haze (1).js @@ -0,0 +1,380 @@ +/* +@title: leafeons_journey +@author: Amukta P +@description: An adventure where you guide a forest fox, avoiding critters and hazards, collecting orbs, and reaching the goal. +@tags: [platformer, adventure, puzzle] +@addedOn: 2025-08-26 +*/ + +// 🌿 Leafeon's Journey — Themed levels, better Leafeon sprite, no errors +// Controls: WASD to move, K to start / restart + +const player = "p" +const orb = "o" +const goal = "g" +const critter = "c" +const tree = "t" +const shrub = "s" +const vine = "v" +const rock = "r" +const flower = "f" +const water = "w" +const sky = "y" +const ground = "d" + +let level = 0 +let score = 0 + +// ---------- Legend (sprites) ---------- +setLegend( + [ player, bitmap` +................ +.......33....... +......32223..... +.....3222223.... +.....3222223.... +......32223..... +.......3333..... +......3..3...... +.....3....3..... +....33....33.... +....3......3.... +....3......3.... +....3......3.... +................ +................ +................` ], + [ orb, bitmap` +................ +................ +.......33....... +......3333...... +.....333333..... +....33333333.... +....33333333.... +.....333333..... +......3333...... +.......33....... +................ +................ +................ +................ +................ +................` ], + [ goal, bitmap` +................ +................ +.......22....... +......2222...... +.....222222..... +....22222222.... +...2222222222... +...2222222222... +....22222222.... +.....222222..... +......2222...... +.......22....... +................ +................ +................ +................` ], + [ critter, bitmap` +................ +......6666...... +.....677776..... +....67777776.... +....67777776.... +.....677776..... +......6666...... +......6..6...... +......6..6...... +......6..6...... +......6666...... +.......66....... +................ +................ +................ +................` ], + [ tree, bitmap` +................ +.....444444..... +....44444444.... +...4444444444... +...4444444444... +....44444444.... +.....444444..... +.......44....... +.......44....... +.......44....... +.......44....... +.......44....... +.......44....... +................ +................ +................` ], + [ shrub, bitmap` +................ +................ +.....333333..... +....33333333.... +...3333333333... +...3333333333... +....33333333.... +.....333333..... +......3333...... +................ +................ +................ +................ +................ +................ +................` ], + [ vine, bitmap` +.......77....... +.......77....... +.......77....... +.......77....... +.......77....... +.......77....... +.......77....... +.......77....... +.......77....... +.......77....... +.......77....... +.......77....... +.......77....... +.......77....... +.......77....... +.......77.......` ], + [ rock, bitmap` +................ +................ +....444444...... +...44444444..... +..4444444444.... +..4444444444.... +...44444444..... +....444444...... +................ +................ +................ +................ +................ +................ +................ +................` ], + [ flower, bitmap` +................ +.......3........ +......333....... +.......3........ +.....33333...... +......333....... +.......3........ +................ +................ +................ +................ +................ +................ +................ +................ +................` ], + [ water, bitmap` +2222222222222222 +2222222222222222 +2222222222222222 +2222222222222222 +2222222222222222 +2222222222222222 +2222222222222222 +2222222222222222 +2222222222222222 +2222222222222222 +2222222222222222 +2222222222222222 +2222222222222222 +2222222222222222 +2222222222222222 +2222222222222222` ], + [ sky, bitmap` +5555555555555555 +5555555555555555 +5555555555555555 +5555555555555555 +5555555555555555 +5555555555555555 +5555555555555555 +5555555555555555 +5555555555555555 +5555555555555555 +5555555555555555 +5555555555555555 +5555555555555555 +5555555555555555 +5555555555555555 +5555555555555555` ], + [ ground, bitmap` +3333333333333333 +3222222222222223 +3223333222333223 +3222222222222223 +3333333333333333 +3222222222222223 +3223333222333223 +3222222222222223 +3333333333333333 +3222222222222223 +3223333222333223 +3222222222222223 +3333333333333333 +3222222222222223 +3223333222333223 +3333333333333333` ] +) + +// ---------- Solids ---------- +setSolids([ tree, rock, shrub ]) + +// ---------- Levels ---------- +const levels = [ + // Intro (16 x 10) + map` +yyyyyyyyyyyyyyyy +ydddddddddddddyd +yd............dy +yd............dy +yd............dy +yd............dy +yd............dy +yd............dy +ydddddddddddddyd +yyyyyyyyyyyyyyyy`, + + // Level 1 (12 x 7) + map` +tttttttttttt +tp..f.o..fgt +t..tt..f...t +t.f..o...f.t +t..tt..o...t +to...c.....t +tttttttttttt`, + + // Level 2 (14 x 7) — fixed, all rows = 14 + map` +tttttttttttttt +tp..o..f..o.gtt +t..ttttwwww..t. +t..o..twwww..t. +t..c.tttww.o.t. +t...o..f..o..t. +tttttttttttttt.`, + + // Level 3 (16 x 7) — fixed, all rows = 16 + map` +tttttttttttttttt +tp.o.v..f..o..gt +t..ttttttt...ctt +t.o..t..o..vv.tt +t....tttttvv..tt +t..c...o....o.tt +tttttttttttttttt` +] + +// ---------- Music ---------- +const bgm = tune` +120: C4~120 + E4~120, +120: G4~120, +120: E4~120, +120: F4~120 + A4~120, +120: C5~120, +120: A4~120, +120: G4~120, +120: E4~120` +playTune(bgm, Infinity) + +// ---------- Boot / HUD ---------- +setMap(levels[level]) +showIntro() + +function showIntro() { + clearText() + addText("Leafeon's Journey", { x: 2, y: 1, color: color`3` }) + addText("WASD = move", { x: 3, y: 3, color: color`4` }) + addText("Collect orbs (o)", { x: 3, y: 4, color: color`2` }) + addText("Avoid critters (c)",{ x: 3, y: 5, color: color`6` }) + addText("Press K to start", { x: 3, y: 7, color: color`7` }) +} + +function drawHUD() { + if (level === 0) return + clearText() + addText("Score: " + score, { x: 0, y: 0, color: color`5` }) +} + +// ---------- Controls ---------- +onInput("w", () => movePlayer(0, -1)) +onInput("s", () => movePlayer(0, 1)) +onInput("a", () => movePlayer(-1, 0)) +onInput("d", () => movePlayer(1, 0)) +onInput("k", () => { + if (level === 0) { + level = 1 + score = 0 + setMap(levels[level]) + drawHUD() + } else { + setMap(levels[level]) + drawHUD() + } +}) + +// ---------- Helpers ---------- +function movePlayer(dx, dy) { + const p = getFirst(player) + if (!p) return + const nx = p.x + dx, ny = p.y + dy + if (getTile(nx, ny).some(s => s.type === tree || s.type === rock || s.type === shrub)) return + p.x = nx; p.y = ny + collectOrbAt(nx, ny) + drawHUD() +} +function collectOrbAt(x, y) { + for (const s of getTile(x, y)) if (s.type === orb) { + s.remove(); score += 10 + } +} + +// ---------- Critter AI ---------- +setInterval(() => { + for (const c of getAll(critter)) { + if (c.dir === undefined) c.dir = 1 + c.x += c.dir + if (c.x <= 0 || c.x >= width() - 1 || getTile(c.x, c.y).some(t => t.type === tree || t.type === rock || t.type === shrub)) { + c.x -= c.dir; c.dir *= -1 + } + } +}, 500) + +// ---------- Rules ---------- +afterInput(() => { + const p = getFirst(player) + if (!p) return + + if (tilesWith(player, critter).length || tilesWith(player, vine).length) { + addText("Ouch!", { x: 4, y: 4, color: color`6` }) + setTimeout(() => { setMap(levels[level]); drawHUD() }, 600) + return + } + + if (tilesWith(player, goal).length && tilesWith(orb).length === 0) { + score += 50; level++ + if (level < levels.length) { setMap(levels[level]); drawHUD() } + else { + clearText() + addText("You Win!", { x: 4, y: 3, color: color`3` }) + addText("Final Score: " + score, { x: 3, y: 5, color: color`5` }) + } + } +})