From 9a822a1833741601e37bb752c9bc13ec8a3d8aa7 Mon Sep 17 00:00:00 2001 From: Nikita Iryupin Date: Sat, 5 Jun 2021 22:22:22 +0200 Subject: [PATCH] Fix HTML and map loop --- public/index.html | 4 ++-- src/GameLogic/gameField.js | 2 +- src/Graphics/Map/mapParser.js | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/public/index.html b/public/index.html index df98006..aa05c8e 100644 --- a/public/index.html +++ b/public/index.html @@ -1,5 +1,5 @@ - + @@ -24,7 +24,7 @@ diff --git a/src/GameLogic/gameField.js b/src/GameLogic/gameField.js index 1912096..bb2bf6a 100644 --- a/src/GameLogic/gameField.js +++ b/src/GameLogic/gameField.js @@ -87,7 +87,7 @@ export class GameField { this.canvas.height = this.height; this.canvas.width = this.width; this.collisionManager.attachMap(this.map); - this.aiTanks.setCount(this.map._enemiesCount); + this.aiTanks.setCount(this.map == null ? null : this.map._enemiesCount); } async play(level, firstTime) { diff --git a/src/Graphics/Map/mapParser.js b/src/Graphics/Map/mapParser.js index f8d54d8..88a4af0 100644 --- a/src/Graphics/Map/mapParser.js +++ b/src/Graphics/Map/mapParser.js @@ -13,8 +13,8 @@ export class MapParser { async getMap(levelNumber, tileset) { let json = this.levelStorage.getLevel(levelNumber); - if (!json) { - let fetchResult = await fetch(`./stages/stage-${levelNumber}.json`); + if (json == null) { + let fetchResult = await fetch(`./stages/stage-${levelNumber}.json`).catch(console.log("Map not found!")); if (!fetchResult.ok) return null; json = await fetchResult.text();