diff --git a/snake/snake-levels.js b/snake/snake-levels.js index c7cd20f..3c0ff44 100644 --- a/snake/snake-levels.js +++ b/snake/snake-levels.js @@ -7,7 +7,7 @@ // Level 1: Hello Snake! - small.push({ + small.levels.push({ "name": "Hello Snake!", "rows":10, "cols":10, "easy": { "fps": 2, "targetScore": 5, "growthFactor": 2, "growthFactorIncrease": 1}, "medium": { "fps": 4, "targetScore": 7, "growthFactor": 2, "growthFactorIncrease": 1}, @@ -26,7 +26,7 @@ 1,1,1,1,1,1,1,1,1,1]}); // Level 2: Room to Grow - small.push({ + small.levels.push({ "name": "Room to Grow", "rows":16, "cols":16, "easy": { "fps":3, "targetScore": 7, "growthFactor": 2, "growthFactorIncrease": 1}, "medium": { "fps":3, "targetScore": 7, "growthFactor": 2, "growthFactorIncrease": 1}, @@ -51,7 +51,7 @@ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]}); // Level 3: North and South - small.push({ + small.levels.push({ "name": "North and South", "rows":15, "cols":15, "easy": { "fps":3, "targetScore": 6, "growthFactor": 2, "growthFactorIncrease": 1}, "medium": { "fps":3, "targetScore": 6, "growthFactor": 2, "growthFactorIncrease": 1}, @@ -75,7 +75,7 @@ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]}); // Level 4: Four Small Rooms - small.push({ + small.levels.push({ "name": "Four Small Rooms","rows":15,"cols":15, "easy": { "fps":3, "targetScore": 5, "growthFactor": 2, "growthFactorIncrease": 1}, "medium": { "fps":3, "targetScore": 5, "growthFactor": 2, "growthFactorIncrease": 1}, @@ -99,7 +99,7 @@ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]}); // Level 5: Polka Dots - small.push({ + small.levels.push({ "name": "Polka Dots" ,"rows":15,"cols":15, "easy": { "fps":3, "targetScore": 5, "growthFactor": 2, "growthFactorIncrease": 1}, "medium": { "fps":3, "targetScore": 5, "growthFactor": 2, "growthFactorIncrease": 1}, @@ -123,7 +123,7 @@ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]}); // Level 6: Toaster Face - small.push({ + small.levels.push({ "name": "Toaster Face","rows":15,"cols":15, "easy": { "fps":3, "targetScore": 5, "growthFactor": 2, "growthFactorIncrease": 1}, "medium": { "fps":3, "targetScore": 5, "growthFactor": 2, "growthFactorIncrease": 1}, @@ -147,7 +147,7 @@ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]}); // Level 7: Wierd Walls - small.push({ + small.levels.push({ "name": "Wierd Walls","rows":15,"cols":15, "easy": { "fps":3, "targetScore": 5, "growthFactor": 2, "growthFactorIncrease": 1}, "medium": { "fps":3, "targetScore": 5, "growthFactor": 2, "growthFactorIncrease": 1}, @@ -171,7 +171,7 @@ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]}); // Level 8: Feast and Famine - small.push({ + small.levels.push({ "name": "Feast and Famine","rows":15,"cols":15, "easy": { "fps":3, "targetScore": 5, "growthFactor": 2, "growthFactorIncrease": 1}, "medium": { "fps":3, "targetScore": 5, "growthFactor": 2, "growthFactorIncrease": 1}, @@ -195,7 +195,7 @@ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]}); // Level 1: Maze 1 - mazes.push({ + mazes.levels.push({ "name": "Maze 1","rows":15,"cols":15, "easy": { "fps":3, "targetScore": 5, "growthFactor": 2, "growthFactorIncrease": 1}, "medium": { "fps":3, "targetScore": 5, "growthFactor": 2, "growthFactorIncrease": 1}, @@ -219,7 +219,7 @@ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]}); // Level 2: Spiral - mazes.push({ + mazes.levels.push({ "name": "Spiral","rows":15,"cols":15, "easy": { "fps":3, "targetScore": 5, "growthFactor": 2, "growthFactorIncrease": 1}, "medium": { "fps":3, "targetScore": 5, "growthFactor": 2, "growthFactorIncrease": 1}, @@ -244,7 +244,7 @@ // Level 3: Maze 2 - mazes.push({ + mazes.levels.push({ "name": "Maze 2","rows":17,"cols":17, "easy": { "fps":3, "targetScore": 5, "growthFactor": 2, "growthFactorIncrease": 1}, "medium": { "fps":3, "targetScore": 5, "growthFactor": 2, "growthFactorIncrease": 1}, @@ -267,8 +267,7 @@ 1,0,1,1,1,1,0,0,0,0,1,1,1,1,1,0,1, 1,0,1,0,0,0,1,1,1,1,0,0,0,1,0,0,1, 1,0,0,0,1,0,0,0,0,0,0,1,0,0,0,1,1, - 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]} - ]); + 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]}); window.SnakeLevels = { "Small Rooms": small, diff --git a/snake/snake-page.js b/snake/snake-page.js new file mode 100644 index 0000000..1f7ba9c --- /dev/null +++ b/snake/snake-page.js @@ -0,0 +1,47 @@ +var $canvas = $("#snakeCanvas"); +var canvasEl = $canvas[0]; +var $scoreValue = $("#score span.value"); +var $levelSelectSection = $("#levelSelect"); + +canvasEl.width = canvasEl.clientWidth; +canvasEl.height = canvasEl.clientHeight; + +var initializePage = function() { + + // Load the snake levels onto the page UI. + _.each(SnakeLevels, function(levelSet, setName) { + var newHtml = "