mirror of
https://git.leinelab.org/Mal/mr-crocs-adventures.git
synced 2025-09-11 02:57:36 +02:00
Get parameters from URL are now possible.
This commit is contained in:
18
js/module.js
18
js/module.js
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user