diff --git a/levels/2.json b/levels/2.json index c8b485d..a8f3740 100644 --- a/levels/2.json +++ b/levels/2.json @@ -1,12 +1,15 @@ { - "minDelay": 100, - "acceleration": 1, "dimensions": [40, 40], + "delay": 200, + "acceleration": 1, + "minDelay": 100, + "walls": [ [5,5], [5,6], [5,7], [5,8], [40, 35], [38, 35], [23, 35] ], "randWallFreq": 5000, + "food": [ [10,10], [11,10], @@ -16,6 +19,7 @@ [20, 23], [20, 21] ], + "randFoodFreq": 2000, "ice": [ [15,15], @@ -32,7 +36,12 @@ [17,18] ], - "randFoodFreq": 2000, + "teleportation": [ + [35, 5], + [5, 35] + ], + + "snake": [ [4,2], [4,1], [3,1], [2,1] ], diff --git a/script.js b/script.js index 311b096..e0162f8 100644 --- a/script.js +++ b/script.js @@ -15,6 +15,7 @@ const WALL = i++; const FOOD = i++; const ICE = i++; const ICE_SNAKE = i++; // If the snake is on the ice +const TELEPORTATION = i++; delete i; /** @@ -194,18 +195,28 @@ async function startGame(gameID) { } /// ... then with cells content + // Walls level.walls.forEach((w) => { map[w[0]-1][w[1]-1] = WALL }) + // Food level.food.forEach((f) => { map[f[0]-1][f[1]-1] = FOOD }) + // Ice if(level.hasOwnProperty("ice")) level.ice.forEach((f) => { map[f[0]-1][f[1]-1] = ICE }) + + // Teleportation + if(level.hasOwnProperty("teleportation")) + level.teleportation.forEach((f) => { + map[f[0]-1][f[1]-1] = TELEPORTATION + }) + level.snake.forEach((s) => { map[s[0]-1][s[1]-1] = SNAKE @@ -328,6 +339,11 @@ async function startGame(gameID) { case FOOD: ctx.drawImage(imgApple, x*cell_width, y*cell_height, cell_width, cell_height); break; + + case TELEPORTATION: + ctx.fillStyle = "gray"; + ctx.fillRect(x*cell_width, y*cell_height, cell_width, cell_height) + break; case ICE: case ICE_SNAKE: