Skip to content

Commit

Permalink
fixing bugs in games which
Browse files Browse the repository at this point in the history
  • Loading branch information
leomcelroy committed Nov 7, 2022
1 parent 4e77dda commit 883550a
Show file tree
Hide file tree
Showing 7 changed files with 94 additions and 72 deletions.
1 change: 0 additions & 1 deletion games/2D_life.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,5 @@ onInput("k", () => {
step();
});
onInput("l", () => {
setMap(levels[level]);
addSprite(0, 0, sel);
});
2 changes: 1 addition & 1 deletion games/3072_A_2048_Spin-Off.js
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ onInput("l", () => {
});

onInput("j", () => {
playback.end();
if (playback) playback.end();
});

//Instructions
Expand Down
78 changes: 35 additions & 43 deletions games/Limits.js
Original file line number Diff line number Diff line change
Expand Up @@ -397,21 +397,21 @@ addText("Level Select", {y: 9, color: color`0`});
//addText(moves.toString(), { x: 1, y: 1, color: color`3` });

onInput("w", () => {
if (moves >= 1) {
if (moves >= 1 && getFirst(player)) {
getFirst(player).y -= 1
moves -= 1;
}
});

onInput("a", () => {
if (moves >= 1) {
if (moves >= 1 && getFirst(player)) {
getFirst(player).x -= 1
moves -= 1;
}
});

onInput("d", () => {
if (moves >= 1) {
if (moves >= 1 && getFirst(player)) {
getFirst(player).x += 1
moves -= 1;
}
Expand All @@ -438,7 +438,7 @@ onInput("s", () => {
level = selected + 1;
setMap(levels[selected + 1]);
}
else if (moves >= 1) {
else if (moves >= 1 && getFirst(player)) {
getFirst(player).y += 1
moves -= 1;
}
Expand Down Expand Up @@ -496,54 +496,46 @@ onInput("l", () => {

afterInput(() => {

try {
if (getFirst(player).x == getFirst(bluePortal).x) {
if (getFirst(player).y == getFirst(bluePortal).y) {
setSolids([solid]);
getFirst(player).x = getFirst(redPortal).x;
getFirst(player).y = getFirst(redPortal).y;
setSolids([player, solid]);
}

if (getFirst(bluePortal) && getFirst(player) && getFirst(player).x == getFirst(bluePortal).x) {
if (getFirst(player).y == getFirst(bluePortal).y) {
setSolids([solid]);
getFirst(player).x = getFirst(redPortal).x;
getFirst(player).y = getFirst(redPortal).y;
setSolids([player, solid]);
}
else if (getFirst(player).x == getFirst(redPortal).x) {
if (getFirst(player).y == getFirst(redPortal).y) {
setSolids([solid]);
getFirst(player).x = getFirst(bluePortal).x;
getFirst(player).y = getFirst(bluePortal).y;
setSolids([player, solid]);
}
}
else if (getFirst(redPortal) && getFirst(player) && getFirst(player).x == getFirst(redPortal).x) {
if (getFirst(player).y == getFirst(redPortal).y) {
setSolids([solid]);
getFirst(player).x = getFirst(bluePortal).x;
getFirst(player).y = getFirst(bluePortal).y;
setSolids([player, solid]);
}
} catch (error){
console.error(error);
}

try {
if (getFirst(player).x == getFirst(move).x) {
if (getFirst(player).y == getFirst(move).y) {
moves += 10;
let x = getFirst(player).x;
let y = getFirst(player).y;
playTune(pickUp);
clearTile(x, y);
addSprite(x, y, player);
}

if (getFirst(player) && getFirst(move) && getFirst(player).x == getFirst(move).x) {
if (getFirst(player).y == getFirst(move).y) {
moves += 10;
let x = getFirst(player).x;
let y = getFirst(player).y;
playTune(pickUp);
clearTile(x, y);
addSprite(x, y, player);
}
} catch (error) {
console.error(error);
}

try {
if (getFirst(player).x == getFirst(win).x) {
if (getFirst(player).y == getFirst(win).y) {
level += 1;
setMap(levels[level]);
moves = 20;
}


if (getFirst(player) && getFirst(win) && getFirst(player).x == getFirst(win).x) {
if (getFirst(player).y == getFirst(win).y) {
level += 1;
setMap(levels[level]);
moves = 20;
}
} catch (error) {
console.error(error);
}


if (level != 0 && level != 12) {
clearText();
addText(moves.toString(), { x: 1, y: 1, color: color`3` });
Expand Down
44 changes: 36 additions & 8 deletions games/Paint_IT.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,14 +196,42 @@ m..............................................................................m
mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm`;
setMap(Canvas)
//================================
onInput("i", () => {addSprite(ax, ay, black);
playTune(w);});
onInput("j", () => {addSprite(bx, by, red);
playTune(s);});
onInput("k", () => {addSprite(cx, cy, blue);
playTune(d);});
onInput("l", () => {addSprite(dx, dy, yellow);
playTune(a);});
onInput("i", () => {
ax = Math.min(width()-1, ax);
ax = Math.max(0, ax);
ay = Math.min(height()-1, ay);
ay = Math.max(0, ay);
addSprite(ax, ay, black);
playTune(w);
});

onInput("j", () => {
bx = Math.min(width()-1, bx);
bx = Math.max(0, bx);
by = Math.min(height()-1, by);
by = Math.max(0, by);
addSprite(bx, by, red);
playTune(s);
});

onInput("k", () => {
cx = Math.min(width()-1, cx);
cx = Math.max(0, cx);
cy = Math.min(height()-1, cy);
cy = Math.max(0, cy);
addSprite(cx, cy, blue);
playTune(d);
});

onInput("l", () => {
dx = Math.min(width()-1, dx);
dx = Math.max(0, dx);
dy = Math.min(height()-1, dy);
dy = Math.max(0, dy);
addSprite(dx, dy, yellow);
playTune(a);
});

//================================
onInput("w", () => {ay--});
onInput("a", () => {ax--});
Expand Down
12 changes: 7 additions & 5 deletions games/QuadraPedal.js
Original file line number Diff line number Diff line change
Expand Up @@ -363,15 +363,17 @@ setPushables({

// START - PLAYER MOVEMENT CONTROLS

const playback = playTune(backgroundMusic, Infinity)
let playback = playTune(backgroundMusic, Infinity)

onInput("i", () => {
playback.end()
if (playback) playback.end()
});

onInput("k", () => {
playback.end()
playTune(backgroundMusic, Infinity)
if (playback) {
playback.end()
playback = playTune(backgroundMusic, Infinity)
}
});

onInput("s", () => {
Expand Down Expand Up @@ -470,7 +472,7 @@ afterInput(() => {
setMap(currentLevel);
} else {
addText("you win!", { y: 4, color: color`3` });
playback.end()
if (playback) playback.end()
playTune(winMusic)
}
}
Expand Down
26 changes: 13 additions & 13 deletions games/seven_ate_nine_(789).js
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,15 @@ const soundStart = tune`
let onW, onA, onS, onD, onI, onJ, onK, onL

function setControlsMovement () {
onW = () => getFirst(seven).y -= 1
onA = () => getFirst(seven).x -= 1
onS = () => getFirst(seven).y += 1
onD = () => getFirst(seven).x += 1
onW = () => { if (getFirst(seven)) getFirst(seven).y -= 1 }
onA = () => { if (getFirst(seven)) getFirst(seven).x -= 1 }
onS = () => { if (getFirst(seven)) getFirst(seven).y += 1 }
onD = () => { if (getFirst(seven)) getFirst(seven).x += 1 }

onI = () => getFirst(nine).y -= 1
onJ = () => getFirst(nine).x -= 1
onK = () => getFirst(nine).y += 1
onL = () => getFirst(nine).x += 1
onI = () => { if (getFirst(nine)) getFirst(nine).y -= 1 }
onJ = () => { if (getFirst(nine)) getFirst(nine).x -= 1 }
onK = () => { if (getFirst(nine)) getFirst(nine).y += 1 }
onL = () => { if (getFirst(nine)) getFirst(nine).x += 1 }
} setControlsMovement()

function countDown () {
Expand Down Expand Up @@ -131,10 +131,10 @@ function sevenAteNine () {
function moveEight () {
if (eightStart === false) return
const direction = eightDirection()
if (eightDirection() === "right") getFirst(eight).x += 1
if (eightDirection() === "left") getFirst(eight).x += -1
if (eightDirection() === "up") getFirst(eight).y += -1
if (eightDirection() === "down") getFirst(eight).y += 1
if (getFirst(eight) && eightDirection() === "right") getFirst(eight).x += 1
if (getFirst(eight) && eightDirection() === "left") getFirst(eight).x += -1
if (getFirst(eight) && eightDirection() === "up") getFirst(eight).y += -1
if (getFirst(eight) && eightDirection() === "down") getFirst(eight).y += 1
if (tilesWith(seven, eight).length === 1) return nineSaved()
setTimeout(moveEight, eightSpeed)
eightSpeed *= eightAccel
Expand Down Expand Up @@ -384,7 +384,7 @@ startGame()
afterInput(() => {
if (tilesWith(seven, nine).length === 1) sevenAteNine()
if (tilesWith(seven, eight).length === 1) nineSaved()
if ((getFirst(nine).x < 2) && (eightStart == false)) {
if (getFirst(nine) && (getFirst(nine).x < 2) && (eightStart == false)) {
eightStart = true
moveEight()
}
Expand Down
3 changes: 2 additions & 1 deletion tests/sprigfuzzy.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,14 @@ async function spadeRun(path) {
// await testScript(slug);

let brokenGames = [];
const SKIP = ["mandelbrot.js"];

async function main() {
brokenGames = [];
for await (const dirEntry of Deno.readDir('./games')) {
const name = dirEntry.name;
const isJS = name.slice(-3) === ".js";
if (!isJS || ["mandelbrot.js"].some(x => x === name)) continue;
if (!isJS || SKIP.some(x => x === name)) continue;
console.log("running", name);
await testScript(name);
}
Expand Down

0 comments on commit 883550a

Please sign in to comment.