Skip to content

Commit

Permalink
added end screen
Browse files Browse the repository at this point in the history
  • Loading branch information
Shadow8928 authored Dec 21, 2024
1 parent e79428d commit 85a4afe
Showing 1 changed file with 67 additions and 22 deletions.
89 changes: 67 additions & 22 deletions games/2Ptag.js
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down Expand Up @@ -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
......
Expand All @@ -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` })
}
})

0 comments on commit 85a4afe

Please sign in to comment.