Graveyard terrain and background tiles implemented

This commit is contained in:
Mal
2025-05-16 23:08:35 +02:00
parent e97c04ed19
commit fc990c12aa
25 changed files with 504 additions and 50 deletions

View File

@@ -6,10 +6,15 @@ export default class Level
{
static FACTOR_GRAVITY = 4.903;
/**
* @param {Terrain} terrain
*/
constructor(terrain)
{
/** @type {Terrain} */
this.terrain = terrain;
this.fullscreenEffects = [];
this.fullscreenEffects = [];
this.gravity = 2.0;
}
@@ -78,7 +83,7 @@ export default class Level
this.gravity = gravity;
}
static createFromFile(filename, callback = () => {})
static createFromFile(filename, onLoad = () => {})
{
let loader = new FileLoader(filename);
loader.onLoad = (data) => {
@@ -86,6 +91,12 @@ export default class Level
const level = new Level(Terrain.createFromJson(json));
level.setGravity(json.gravity / Level.FACTOR_GRAVITY);
for (const oldEffect of level.fullscreenEffects) {
oldEffect.destroy();
}
level.fullscreenEffects = [];
if (json.hasOwnProperty('effects')) {
const effectFactory = new FullscreenEffectFactory();
@@ -96,7 +107,7 @@ export default class Level
}
}
callback(level);
onLoad(level);
}
loader.loadContent();
}
@@ -109,6 +120,12 @@ export default class Level
const level = new Level(terrain);
level.setGravity(data.gravity / Level.FACTOR_GRAVITY);
for (const oldEffect of level.fullscreenEffects) {
oldEffect.destroy();
}
level.fullscreenEffects = [];
if (data.hasOwnProperty('effects')) {
const effectFactory = new FullscreenEffectFactory();