Current directory: /home/klas4s23/domains/585455.klas4s23.mid-ica.nl/public_html/Gastenboek/uploads
function newLevel()
{
document.getElementById("level").innerHTML = `Level ${level}`;
switch (level)
{
case 1:
mapW = 9;
mapH = 9;
playerX = 4;
playerY = 4;
playerRotation = 0;
mapTiles = [
[1, 1, 1, 1, 1, 1, 1, 1, 1],
[1, 0, 0, 0, 0, 0, 0, 0, 1],
[1, 0, 2, 0, 0, 0, 2, 0, 1],
[1, 0, 0, 0, 0, 0, 0, 0, 1],
[1, 0, 0, 0, 0, 0, 0, 0, 1],
[1, 0, 0, 0, 0, 0, 0, 0, 1],
[1, 0, 2, 0, 0, 0, 2, 0, 1],
[1, 0, 0, 0, 0, 0, 0, 0, 1],
[1, 1, 1, 1, 1, 1, 1, 1, 1]
];
tileData = [
[0, 0, 0, 0, 0, 0, 0, 0, 0],
[2, 0, 0, 0, 0, 0, 0, 0, 1],
[2, 0, [4, 4, 4, 4], 0, 0, 0, [4, 4, 4, 4], 0, 1],
[2, 0, 0, 0, 0, 0, 0, 0, 1],
[2, 0, 0, 0, 0, 0, 0, 0, 1],
[2, 0, 0, 0, 0, 0, 0, 0, 1],
[2, 0, [4, 4, 4, 4], 0, 0, 0, [4, 4, 4, 4], 0, 1],
[2, 0, 0, 0, 0, 0, 0, 0, 1],
[0, 0, 0, 0, 0, 0, 0, 0, 0]
];
boxData = Array.from(Array(mapH), () => new Array(mapW).fill(false));
boxData[2][4] = true;
boxData[4][2] = true;
boxData[6][4] = true;
boxData[4][6] = true;
break;
case 2:
mapW = 6;
mapH = 6
playerX = 1;
playerY = 3;
playerRotation = 1;
mapTiles = [
[1, 1, 1, 1, 1, 1],
[1, 0, 0, 0, 0, 1],
[1, 0, 1, 0, 0, 1],
[1, 0, 0, 2, 2, 1],
[1, 0, 0, 0, 0, 1],
[1, 1, 1, 1, 1, 1]
];
tileData = [
[0, 0, 0, 0, 0, 0],
[2, 0, 0, 0, 0, 1],
[2, 0, 3, 0, 0, 1],
[2, 0, 0, [4, 3, 2, 4], [2, 4, 4, 3], 1],
[2, 0, 0, 0, 0, 1],
[0, 0, 0, 0, 0, 0]
];
boxData = Array.from(Array(mapH), () => new Array(mapW).fill(false));
boxData[3][2] = true;
boxData[3][3] = true;
break;
case 3:
mapW = 7;
mapH = 10;
playerX = 3;
playerY = 6;
playerRotation = 0;
mapTiles = [
[1, 1, 1, 1, 1, 1, 1],
[1, 1, 0, 2, 2, 1, 1],
[1, 1, 0, 2, 0, 1, 1],
[1, 1, 2, 2, 2, 1, 1],
[1, 1, 1, 0, 1, 1, 1],
[1, 0, 0, 0, 0, 0, 1],
[1, 0, 0, 0, 0, 0, 1],
[1, 0, 0, 0, 0, 0, 1],
[1, 0, 0, 0, 0, 0, 1],
[1, 1, 1, 1, 1, 1, 1]
];
tileData = [
[0, 0, 0, 0, 0, 0, 0],
[0, 2, 0, [4, 3, 1, 2], [2, 4, 4, 3], 1, 0],
[0, 2, 0, [3, 2, 3, 2], 0, 1, 0],
[0, 2, [4, 3, 2, 4], [1, 1, 2, 3], [2, 4, 4, 3], 1, 0],
[0, 0, 2, 0, 1, 0, 0],
[2, 0, 0, 0, 0, 0, 1],
[2, 0, 0, 0, 0, 0, 1],
[2, 0, 0, 0, 0, 0, 1],
[2, 0, 0, 0, 0, 0, 1],
[0, 0, 0, 0, 0, 0, 0]
];
boxData = Array.from(Array(mapH), () => new Array(mapW).fill(false));
boxData[5][2] = true;
boxData[5][4] = true;
boxData[6][2] = true;
boxData[6][4] = true;
boxData[7][2] = true;
boxData[7][4] = true;
break;
case 4:
mapW = 8;
mapH = 8;
playerX = 6;
playerY = 5;
playerRotation = 0;
mapTiles = [
[1, 1, 1, 1, 1, 1, 1, 1],
[1, 0, 0, 0, 1, 0, 2, 1],
[1, 0, 0, 0, 0, 0, 2, 1],
[1, 0, 0, 1, 1, 0, 2, 1],
[1, 1, 0, 0, 1, 0, 0, 1],
[1, 1, 0, 0, 1, 0, 0, 1],
[1, 1, 0, 0, 1, 0, 0, 1],
[1, 1, 1, 1, 1, 1, 1, 1]
];
tileData = [
[0, 0, 0, 0, 0, 0, 0, 0],
[2, 0, 0, 0, 3, 0, [4, 4, 3, 2], 1],
[2, 0, 0, 0, 0, 0, [3, 2, 3, 2], 1],
[2, 0, 0, 1, 2, 0, [3, 2, 4, 4], 1],
[0, 2, 0, 0, 3, 0, 0, 1],
[0, 2, 0, 0, 3, 0, 0, 1],
[0, 2, 0, 0, 3, 0, 0, 1],
[0, 0, 0, 0, 0, 0, 0, 0]
];
boxData = Array.from(Array(mapH), () => new Array(mapW).fill(false));
boxData[2][5] = true;
boxData[3][5] = true;
boxData[5][5] = true;
break;
case 5:
mapW = 7;
mapH = 7;
playerX = 1;
playerY = 4;
playerRotation = 0;
mapTiles = [
[1, 1, 1, 1, 1, 1, 1],
[1, 2, 1, 1, 1, 1, 1],
[1, 2, 0, 0, 0, 0, 1],
[1, 0, 0, 0, 1, 0, 1],
[1, 0, 1, 0, 0, 0, 1],
[1, 0, 0, 2, 1, 1, 1],
[1, 1, 1, 1, 1, 1, 1]
];
tileData = [
[0, 0, 0, 0, 0, 0, 0],
[2, [4, 4, 3, 2], 1, 0, 0, 0, 0],
[2, [3, 2, 4, 4], 0, 0, 0, 0, 1],
[2, 0, 0, 0, 3, 0, 1],
[2, 0, 3, 0, 0, 0, 1],
[2, 0, 0, [4, 4, 4, 4], 1, 0, 0],
[0, 0, 0, 0, 0, 0, 0]
];
boxData = Array.from(Array(mapH), () => new Array(mapW).fill(false));
boxData[2][4] = true;
boxData[3][2] = true;
boxData[4][3] = true;
break;
case 6:
mapW = 8;
mapH = 8;
playerX = 6;
playerY = 2;
playerRotation = 0;
mapTiles = [
[1, 1, 1, 1, 1, 1, 1, 1],
[1, 1, 1, 1, 1, 0, 0, 1],
[1, 1, 1, 1, 0, 0, 0, 1],
[1, 1, 1, 1, 0, 0, 0, 1],
[1, 2, 2, 1, 0, 0, 1, 1],
[1, 0, 0, 0, 0, 0, 1, 1],
[1, 0, 2, 0, 0, 0, 1, 1],
[1, 1, 1, 1, 1, 1, 1, 1]
];
tileData = [
[0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 2, 0, 0, 1],
[0, 0, 0, 2, 0, 0, 0, 1],
[0, 0, 0, 2, 0, 0, 0, 1],
[2, [4, 3, 2, 4], [2, 4, 4, 3], 3, 0, 0, 1, 0],
[2, 0, 0, 0, 0, 0, 1, 0],
[2, 0, [4, 4, 4, 4], 0, 0, 0, 1, 0],
[0, 0, 0, 0, 0, 0, 0, 0]
];
boxData = Array.from(Array(mapH), () => new Array(mapW).fill(false));
boxData[2][5] = true;
boxData[3][5] = true;
boxData[4][5] = true;
break;
case 7:
mapW = 10;
mapH = 8;
playerX = 7;
playerY = 1;
playerRotation = 2;
mapTiles = [
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
[1, 1, 1, 1, 1, 0, 0, 0, 0, 1],
[1, 1, 1, 1, 1, 0, 0, 0, 0, 1],
[1, 1, 1, 1, 1, 1, 1, 0, 0, 1],
[1, 0, 0, 0, 2, 2, 1, 0, 0, 1],
[1, 0, 0, 0, 1, 0, 0, 0, 0, 1],
[1, 1, 1, 2, 2, 0, 0, 0, 2, 1],
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
];
tileData = [
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 2, 0, 0, 0, 0, 1],
[0, 0, 0, 0, 2, 0, 0, 0, 0, 1],
[0, 0, 0, 0, 0, 0, 2, 0, 0, 1],
[2, 0, 0, 0, [4, 3, 2, 4], [2, 4, 4, 3], 3, 0, 0, 1],
[2, 0, 0, 0, 3, 0, 0, 0, 0, 1],
[0, 0, 2, [4, 3, 2, 4], [2, 4, 4, 3], 0, 0, 0, [4, 4, 4, 4], 1],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
];
boxData = Array.from(Array(mapH), () => new Array(mapW).fill(false));
boxData[2][7] = true;
boxData[2][8] = true;
boxData[3][7] = true;
boxData[5][2] = true;
boxData[5][6] = true;
break;
case 8:
mapW = 9;
mapH = 8;
playerX = 1;
playerY = 1;
playerRotation = 1;
mapTiles = [
[1, 1, 1, 1, 1, 1, 1, 1, 1],
[1, 0, 0, 0, 1, 1, 1, 1, 1],
[1, 0, 0, 0, 0, 0, 0, 0, 1],
[1, 0, 1, 1, 1, 0, 0, 0, 1],
[1, 2, 1, 1, 1, 0, 0, 1, 1],
[1, 2, 0, 1, 1, 0, 0, 1, 1],
[1, 2, 2, 2, 0, 0, 0, 1, 1],
[1, 1, 1, 1, 1, 1, 1, 1, 1]
];
tileData = [
[0, 0, 0, 0, 0, 0, 0, 0, 0],
[2, 0, 0, 0, 1, 0, 0, 0, 0],
[2, 0, 0, 0, 0, 0, 0, 0, 1],
[2, 0, 1, 0, 2, 0, 0, 0, 1],
[2, [4, 4, 3, 2], 1, 0, 2, 0, 0, 1, 0],
[2, [3, 2, 3, 2], 0, 1, 2, 0, 0, 1, 0],
[2, [3, 1, 2, 4], [2, 3, 2, 3], [2, 4, 4, 3], 0, 0, 0, 1, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0]
];
boxData = Array.from(Array(mapH), () => new Array(mapW).fill(false));
boxData[2][1] = true;
boxData[2][2] = true;
boxData[2][4] = true;
boxData[3][5] = true;
boxData[5][6] = true;
break;
case 9:
mapW = 8;
mapH = 9;
playerX = 1;
playerY = 2;
playerRotation = 1;
mapTiles = [
[1, 1, 1, 1, 1, 1, 1, 1],
[1, 1, 0, 0, 0, 2, 1, 1],
[1, 0, 0, 0, 0, 0, 1, 1],
[1, 0, 0, 1, 0, 0, 1, 1],
[1, 1, 0, 1, 0, 0, 0, 1],
[1, 0, 0, 1, 2, 2, 0, 1],
[1, 0, 0, 1, 1, 0, 2, 1],
[1, 0, 0, 1, 1, 1, 1, 1],
[1, 1, 1, 1, 1, 1, 1, 1]
];
tileData = [
[0, 0, 0, 0, 0, 0, 0, 0],
[0, 2, 0, 0, 0, [4, 4, 4, 4], 1, 0],
[2, 0, 0, 0, 0, 0, 1, 0],
[2, 0, 0, 3, 0, 0, 1, 0],
[0, 2, 0, 3, 0, 0, 0, 1],
[2, 0, 0, 3, [4, 3, 2, 4], [2, 4, 4, 3], 0, 1],
[2, 0, 0, 1, 2, 0, [4, 4, 4, 4], 1],
[2, 0, 0, 1, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0]
];
boxData = Array.from(Array(mapH), () => new Array(mapW).fill(false));
boxData[1][4] = true;
boxData[3][2] = true;
boxData[3][5] = true;
boxData[4][4] = true;
break;
case 10:
mapW = 9;
mapH = 7;
playerX = 1;
playerY = 3;
playerRotation = 1;
mapTiles = [
[1, 1, 1, 1, 1, 1, 1, 1, 1],
[1, 1, 1, 1, 1, 1, 0, 0, 1],
[1, 1, 1, 1, 0, 0, 0, 0, 1],
[1, 2, 2, 2, 0, 0, 0, 0, 1],
[1, 0, 0, 0, 0, 0, 0, 0, 1],
[1, 1, 1, 1, 1, 1, 2, 2, 1],
[1, 1, 1, 1, 1, 1, 1, 1, 1]
];
tileData = [
[0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 2, 0, 0, 1],
[0, 0, 0, 2, 0, 0, 0, 0, 1],
[2, [4, 3, 2, 4], [2, 3, 2, 3], [2, 4, 4, 3], 0, 0, 0, 0, 1],
[2, 0, 0, 0, 0, 0, 0, 0, 1],
[0, 0, 0, 0, 0, 2, [4, 3, 2, 4], [2, 4, 4, 3], 1],
[0, 0, 0, 0, 0, 0, 0, 0, 0]
];
boxData = Array.from(Array(mapH), () => new Array(mapW).fill(false));
boxData[2][5] = true;
boxData[3][2] = true;
boxData[4][2] = true;
boxData[4][4] = true;
boxData[4][7] = true;
break;
case 11:
mapW = 13;
mapH = 7;
playerX = 1;
playerY = 3;
playerRotation = 1;
mapTiles = [
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
[1, 0, 0, 0, 0, 0, 1, 2, 0, 0, 0, 2, 1],
[1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1],
[1, 0, 0, 3, 0, 0, 1, 0, 0, 3, 0, 0, 1],
[1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1],
[1, 0, 0, 0, 0, 0, 1, 2, 0, 0, 0, 2, 1],
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
];
tileData = [
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[2, 0, 0, 0, 0, 0, 3, [4, 4, 4, 4], 0, 0, 0, [4, 4, 4, 4], 1],
[2, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 1],
[2, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 1],
[2, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 1],
[2, 0, 0, 0, 0, 0, 3, [4, 4, 4, 4], 0, 0, 0, [4, 4, 4, 4], 1],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
];
boxData = Array.from(Array(mapH), () => new Array(mapW).fill(false));
boxData[2][2] = true;
boxData[2][4] = true;
boxData[4][2] = true;
boxData[4][4] = true;
portalData = Array.from(Array(mapH), () => new Array(mapW).fill(0));
portalData[3][9] = 1;
portalPositions = [[[9, 3], [3, 3]]];
break;
}
canvas.width = mapW * cellW;
canvas.height = mapH * cellH;
win = 2;
}
function gotolevel()
{
level = parseInt(document.getElementById("levelselect").value);
newLevel();
renderMap(mapW, mapH);
}
function resetLevel()
{
newLevel();
renderMap(mapW, mapH);
}
function resetHighscore()
{
if (confirm('Are you sure you want to reset the highscore? This will remove all of your progress!'))
{
highscore = 0;
setCookie("highscore", highscore, 365);
document.getElementById("highscore").innerHTML = `Highscore: ${highscore}`;
addOptions();
level = 1;
newLevel();
renderMap(mapW, mapH);
}
}