From 85a4afe3ccca1e57ed283f79773e731a7773a5c7 Mon Sep 17 00:00:00 2001 From: Shadow8928 <92939107+Shadow8928@users.noreply.github.com> Date: Fri, 20 Dec 2024 21:12:04 -0600 Subject: [PATCH] added end screen --- games/2Ptag.js | 89 +++++++++++++++++++++++++++++++++++++------------- 1 file changed, 67 insertions(+), 22 deletions(-) diff --git a/games/2Ptag.js b/games/2Ptag.js index 6bdde3c7d4..2f02b36ea7 100644 --- a/games/2Ptag.js +++ b/games/2Ptag.js @@ -4,13 +4,15 @@ @tags: [] @addedOn: 2024-12-14 */ - +var end = 0 const player = "p" const player1 = "q" const pl1_win = tune` 16000` const pl2_win = tune` 16000` +const win = "w" +const win2 = "s" var turn = 1; setLegend( [player, bitmap` @@ -46,13 +48,48 @@ setLegend( ......000....... ......0.0....... .....00.00...... +................`], + [win, bitmap` +................ +................ +................ +................ +.0.0.0.000.0...0 +.0.0.0.0.0.00..0 +.0.0.0.0.0.0.0.0 +.0.0.0.0.0.0..00 +.00000.000.0...0 +................ +.000.00......... +.0.0..0......... +.000..0......... +.0....0......... +.0....0......... +................`], + [win2, bitmap` +................ +................ +................ +................ +.0.0.0.000.0...0 +.0.0.0.0.0.00..0 +.0.0.0.0.0.0.0.0 +.0.0.0.0.0.0..00 +.00000.000.0...0 +................ +.000..000....... +.0.0....0....... +.000..000....... +.0....0.0....... +.0....00000..... ................`] + ) setSolids([]) let level = 0 -const levels = [ +var levels = [ map` .....q ...... @@ -71,80 +108,88 @@ pl2 = getFirst(player1) onInput("s", () => { if (turn == 1) { pl1.y += 1 - turn = 2; + if (pl1.x == pl2.x && pl1.y == pl2.y) { + turn = 3 + playTune(pl1_win) + end = 1 + } } }) onInput("w", () => { if (turn == 1) { getFirst(player).y -= 1 - turn = 2; if (pl1.x == pl2.x && pl1.y == pl2.y) { turn = 3 playTune(pl1_win) + end = 1 } } }) onInput("a", () => { if (turn == 1) { getFirst(player).x -= 1 - turn = 2; if (pl1.x == pl2.x && pl1.y == pl2.y) { turn = 3 playTune(pl1_win) + end = 1 } } }) onInput("d", () => { if (turn == 1) { getFirst(player).x += 1 - turn = 2; if (pl1.x == pl2.x && pl1.y == pl2.y) { turn = 3 playTune(pl1_win) + end = 1 } } }) onInput("k", () => { - if (turn == 2) { - getFirst(player1).y += 2 - turn = 1; + if (turn == 1) { + getFirst(player1).y += 1 if (pl1.x == pl2.x && pl1.y == pl2.y) { turn = 3 playTune(pl2_win) + end = 2 } } }) onInput("i", () => { - if (turn == 2) { - getFirst(player1).y -= 2 - turn = 1; + if (turn == 1) { + getFirst(player1).y -= 1 if (pl1.x == pl2.x && pl1.y == pl2.y) { - turn = 3 playTune(pl2_win) + end = 2 + turn = 3 } } }) onInput("j", () => { - if (turn == 2) { - getFirst(player1).x -= 2 - turn = 1; + if (turn == 1) { + getFirst(player1).x -= 1 if (pl1.x == pl2.x && pl1.y == pl2.y) { - turn = 3 playTune(pl2_win) + end = 2 + turn = 3 } } }) onInput("l", () => { - if (turn == 2) { - getFirst(player1).x += 2 - turn = 1; + if (turn == 1) { + getFirst(player1).x += 1 if (pl1.x == pl2.x && pl1.y == pl2.y) { - turn = 3 playTune(pl2_win) + end = 2 + turn = 3 } } }) afterInput(() => { - + if (end == 1) { + addText("Player 1 Wins!", { x: 5, y: 5, color: color`0` }) + } else if (end == 2) { + addText("Player 2 Wins!", { x: 5, y: 5, color: color`0` }) + } })