var levelsJSON = [ { "playerStartPosition": {"x": 0.0, "y": -1.0, "z": 6.0}, "bottomHeight": -4.0, "platforms": [ {"left": -1.0, "right": 1.0, "back": -2.0, "front": 2.0, "y": -1.0}, {"left": -2.0, "right": 0.0, "back": -10.0, "front": -4.0, "y": -0.5}, {"left": -0.5, "right": 0.5, "back": 2.0, "front": 7.0, "y": -2.0} ], "goal": {"left": -2.0, "right": 0.0, "bottom": -0.5, "top": 1.5, "z": -10.0} }, { "playerStartPosition": {"x": 0.0, "y": 0.0, "z": 2.5}, "bottomHeight": -4.0, "platforms": [ {"left": -1.0, "right": 1.0, "back": -1.0, "front": 3.0, "y": 0.0}, {"left": 4.0, "right": 5.0, "back": -1.0, "front": 1.0, "y": 0.0}, {"left": 6.0, "right": 7.0, "back": -5.0, "front": 1.0, "y": 1.5} ], "goal": {"left": 6.0, "right": 7.0, "bottom": 1.5, "top": 4.0, "z": -5.0} }, { "playerStartPosition": {"x": 0.0, "y": 8.0, "z": 7.0}, "bottomHeight": -2.0, "platforms": [ {"left": -0.5, "right": 0.5, "back": 0.0, "front": 7.3, "y": 0.0}, {"left": -2.625, "right": -1.375, "back": -0.125, "front": 1.125, "y": 1.5}, {"left": -2.5, "right": -1.5, "back": 2.0, "front": 3.0, "y": 3.0}, {"left": -2.5, "right": -1.5, "back": 4.0, "front": 5.0, "y": 4.5}, {"left": -0.375, "right": 0.375, "back": 4.125, "front": 4.875, "y": 6.0}, {"left": 1.625, "right": 2.375, "back": 4.125, "front": 4.875, "y": 7.5}, {"left": 1.75, "right": 2.25, "back": 2.25, "front": 2.75, "y": 9.0}, {"left": 1.75, "right": 2.25, "back": 0.25, "front": 0.75, "y": 10.5}, {"left": 1.0, "right": 3.0, "back": -4.0, "front": -3.0, "y": 11.0} ], "goal": {"left": 1.0, "right": 3.0, "bottom": 11.0, "top": 13.0, "z": -4.0} }, { "playerStartPosition": {"x": 0.0, "y": 0.0, "z": 0.0}, "bottomHeight": -10, "platforms": [ {"left": -1.0, "right": 1.0, "back": -1.0, "front": 1.0, "y": 0.0}, {"left": -1.0, "right": 1.0, "back": 4.0, "front": 6.0, "y": -2.0}, {"left": -2.0, "right": 2.0, "back": 7.0, "front": 11.0, "y": -3.0}, {"left": 1.5, "right": 2.0, "back": 11.0, "front": 16.0, "y": -3.0}, {"left": -2.0, "right": 1.5, "back": 15.5, "front": 16.0, "y": -3.0}, {"left": -2.0, "right": -1.5, "back": 16.0, "front": 21.0, "y": -3.0}, {"left": -1.5, "right": 2.0, "back": 20.625, "front": 21.0, "y": -3.0}, {"left": 1.625, "right": 2.0, "back": 21.0, "front": 26.0, "y": -3.0}, {"left": -0.75, "right": 0.75, "back": 25.625, "front": 26.0, "y": -3.0}, {"left": -2.0, "right": -1.625, "back": 25.625, "front": 27.0, "y": -3.0}, {"left": -2.0, "right": -1.625, "back": 29.0, "front": 30.0, "y": -3.0}, {"left": -2.0, "right": -1.625, "back": 32.0, "front": 35.0, "y": -3.0}, {"left": -1.5, "right": -1.125, "back": 34.625, "front": 35.0, "y": -1.5}, {"left": -1.0, "right": -0.625, "back": 34.625, "front": 35.0, "y": 0.0}, {"left": -0.5, "right": -0.125, "back": 34.625, "front": 35.0, "y": 1.5}, {"left": 0.0, "right": 0.375, "back": 34.625, "front": 35.0, "y": 3.0}, {"left": 0.5, "right": 0.875, "back": 34.625, "front": 35.0, "y": 4.5}, {"left": 1.0, "right": 1.375, "back": 34.625, "front": 35.0, "y": 6.0}, {"left": -0.5, "right": 0.5, "back": 32.0, "front": 33.0, "y": 7.0}, {"left": -1.5, "right": -0.5, "back": 29.0, "front": 30.0, "y": 7.0}, {"left": -0.5, "right": 0.5, "back": 23.0, "front": 27.0, "y": 7.0} ], "goal": {"left": -0.5, "right": 0.5, "bottom": 7.0, "top": 8.0, "z": 23.0} }, { "playerStartPosition": {"x": 0.0, "y": 0.0, "z": 0.0}, "bottomHeight": -3.0, "platforms": [ {"left": -1.0, "right": 1.0, "back": -1.0, "front": 1.0, "y": 0.0}, {"left": 3.5, "right": 4.5, "back": -0.5, "front": 0.5, "y": 6.0}, {"left": 0.0, "right": 1.0, "back": -0.5, "front": 0.5, "y": 15.0}, {"left": 1.5, "right": 2.25, "back": -20.0, "front": -12.75, "y": 17.0}, {"left": 1.25, "right": 2.5, "back": -25.0, "front": -23.0, "y": 16.75}, {"left": 1.0, "right": 2.75, "back": -27.0, "front": -26.0, "y": 18.0} ], "trampolines": [ {"left": 3.5, "right": 4.5, "back": -0.5, "front": 0.5, "y": 0.0, "yforce": 0.2}, {"left": 0.0, "right": 1.0, "back": -0.5, "front": 0.5, "y": 7.0, "yforce": 0.125}, {"left": -3.5, "right": -2.5, "back": -0.5, "front": 0.5, "y": 9.0, "yforce": 0.125}, {"left": 0.0, "right": 1.0, "back": -0.5, "front": 0.5, "y": 11.0, "yforce": 0.125}, {"left": -3.5, "right": -2.5, "back": -0.5, "front": 0.5, "y": 13.0, "yforce": 0.125}, {"left": 0.0, "right": 1.0, "back": -4.0, "front": -3.0, "y": 15.0, "yforce": 0.25}, {"left": 1.5, "right": 2.25, "back": -27.0, "front": -20.0, "y": 17.0, "yforce": 0.03} ], "goal": {"left": 1.0, "right": 2.75, "bottom": 18.0, "top": 20.0, "z": -27.0} } ]; GameLevels = new Object(); GameLevels.createLevel = function(levelIndex) { var platforms = new Array(); var trampolines = new Array(); var playerStartPosition; var bottomHeight; var goal; for (var platformIndex = 0; platformIndex < levelsJSON[levelIndex]["platforms"].length; platformIndex++) { var platformJSON = levelsJSON[levelIndex]["platforms"][platformIndex]; platforms.push(new Platform(platformJSON["left"], platformJSON["right"], platformJSON["back"], platformJSON["front"], platformJSON["y"])); } if (levelsJSON[levelIndex]["trampolines"] !== undefined) { for (var trampolineIndex = 0; trampolineIndex < levelsJSON[levelIndex]["trampolines"].length; trampolineIndex++) { var trampolineJSON = levelsJSON[levelIndex]["trampolines"][trampolineIndex]; trampolines.push(new Trampoline(trampolineJSON["left"], trampolineJSON["right"], trampolineJSON["back"], trampolineJSON["front"], trampolineJSON["y"], trampolineJSON["yforce"])); } } var playerStartPositionJSON = levelsJSON[levelIndex]["playerStartPosition"]; playerStartPosition = Vector3.withValues(playerStartPositionJSON["x"], playerStartPositionJSON["y"], playerStartPositionJSON["z"]); bottomHeight = levelsJSON[levelIndex]["bottomHeight"]; var goalJSON = levelsJSON[levelIndex]["goal"]; goal = new Goal(goalJSON["left"], goalJSON["right"], goalJSON["bottom"], goalJSON["top"], goalJSON["z"]); return new GameLevel(playerStartPosition, bottomHeight, platforms, trampolines, goal); } GameLevels.numberOfLevels = function() { return levelsJSON.length; }