diff --git a/script.js b/script.js index e0162f8..420c860 100644 --- a/script.js +++ b/script.js @@ -212,9 +212,11 @@ async function startGame(gameID) { }) // Teleportation + const teleportationCells = [] if(level.hasOwnProperty("teleportation")) level.teleportation.forEach((f) => { map[f[0]-1][f[1]-1] = TELEPORTATION + teleportationCells.push(JSON.stringify([f[0]-1,f[1]-1])); }) @@ -297,6 +299,10 @@ async function startGame(gameID) { if(!increaseSize) { const oldPos = snake.shift() map[oldPos[0]][oldPos[1]] = map[oldPos[0]][oldPos[1]] == ICE_SNAKE ? ICE : EMPTY + + // If the cell was a teleportation cell, then revert it back to the right state + if(teleportationCells.includes(JSON.stringify(oldPos))) + map[oldPos[0]][oldPos[1]] = TELEPORTATION } // Check if the user has won