Get parameters from URL are now possible.

This commit is contained in:
Mal
2020-02-16 19:39:44 +01:00
parent d4f3ac969f
commit aa1e2c7116
2 changed files with 76 additions and 1 deletions

View File

@@ -11,6 +11,7 @@ import GraphicSet from "./GraphicSet.js";
import ImageLoader from "./ImageLoader.js";
import Level from "./Level.js";
import InterfaceEvent from "./events/InterfaceEvent.js";
import UrlParam from "./UrlParam.js";
function MainLoop(timestamp)
{
@@ -124,7 +125,22 @@ function MainLoop(timestamp)
window.requestAnimationFrame(MainLoop);
}
let level = Level.createFromFile('levels/test(2).json');
const LEVEL = [
'level01.json',
'moon.json',
'moonbase.json',
'terrain8.json',
];
let urlGetter = new UrlParam();
let levelIndex = urlGetter.getInt('level');
if (levelIndex === undefined || levelIndex < 0 || levelIndex >= LEVEL.length) {
levelIndex = 0;
}
let level = Level.createFromFile(Setting.LEVELS_LOCATION + LEVEL[levelIndex]);
const GAME_SPEED = 1;
const GRAVITY = level.gravity;