Widgets implemented.

This commit is contained in:
Mal
2020-02-04 21:42:14 +01:00
parent d893483da9
commit d46b195269
11 changed files with 197 additions and 45 deletions

View File

@@ -134,8 +134,8 @@ const GAME_SPEED = 1;
const GRAVITY = 2;
let levelJson = new FileLoader('levels/test_stairs.json');
console.log(levelJson.getContent());
const LEVEL = levelJson.getContent();
const LEVEL = JSON.parse(levelJson.getContent());
let lastRendered = undefined;
let lastTimestamp = undefined;
@@ -177,11 +177,11 @@ window.addEventListener(
context = canvas.getContext('2d');
architecture = RetroArchitecture.createFromJson(LEVEL);
architecture = RetroArchitecture.createFromData(LEVEL);
mrCroc = new MrCroc();
mrCroc.position.x = 250;
mrCroc.position.y = 0;
mrCroc.position.x = architecture.tileWidth * LEVEL.startX + architecture.tileWidth * 0.5;
mrCroc.position.y = architecture.tileHeight * LEVEL.startY;
window.requestAnimationFrame(MainLoop);
}

View File

@@ -163,10 +163,8 @@ export default class RetroArchitecture
}
}
static createFromJson(json)
static createFromData(data)
{
let data = JSON.parse(json);
let tileset = new RetroSprite(data.tileset, data.scale);
let architecture = new RetroArchitecture(