From 4aa6289f50482d71b56ec6ac3c6d2aa2ded73a0d Mon Sep 17 00:00:00 2001 From: Nikita Iryupin Date: Sat, 5 Jun 2021 14:50:25 +0200 Subject: [PATCH] Add default spawn of tank --- public/stages/stage-1.json | 2 +- public/stages/stage-2.json | 2 +- src/GameLogic/gameField.js | 7 ++++--- src/constants.js | 3 +++ 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/public/stages/stage-1.json b/public/stages/stage-1.json index ddac98d..d9c7f5c 100644 --- a/public/stages/stage-1.json +++ b/public/stages/stage-1.json @@ -15,7 +15,7 @@ "X Bf X Bf X B8 Bc B4 X Bf X Bf X ", "X X X X X Ba Ef B5 X X X X X " ], - "bots": 20, + "bots": 1, "size": { "width": 13, "height": 13 diff --git a/public/stages/stage-2.json b/public/stages/stage-2.json index 5a5523f..c8c3b9a 100644 --- a/public/stages/stage-2.json +++ b/public/stages/stage-2.json @@ -15,7 +15,7 @@ "X BF X X X B8 BC B4 X BF X BF X ", "X BF X BF X BA Ef B5 X BF BF BF X " ], - "bots": 20, + "bots": 1, "size": { "width": 13, "height": 13 diff --git a/src/GameLogic/gameField.js b/src/GameLogic/gameField.js index 641ae46..de8161b 100644 --- a/src/GameLogic/gameField.js +++ b/src/GameLogic/gameField.js @@ -88,6 +88,9 @@ export class GameField { async play(level) { this.ctx.clearRect(0,0, this.width, this.height); + this.tank.x = Constants.TANK_DEFAULT_SPAWN_X.getValue(); + this.tank.y = Constants.TANK_DEFAULT_SPAWN_Y.getValue(); + this.aiTanks = new AITankManager(this.collisionManager); if (!this.tileset || !this.map || this.map.mapLevel != level) { $(".loading").show(); $(".text-loading").show(); @@ -108,13 +111,11 @@ export class GameField { } lose() { - this.soundManager.playSound(SoundEnum.GameOver); requestAnimationFrame(() => this.drawFieldRecursive()) } - win() { - + win() { this.play(this.map.mapLevel + 1); } diff --git a/src/constants.js b/src/constants.js index e59f10b..b4f2491 100644 --- a/src/constants.js +++ b/src/constants.js @@ -3,6 +3,9 @@ export class Constants { static TANK_SIZE = new Constants(24); static TANK_COLL_OFFSET = new Constants(0.05); static TANK_SPEED = new Constants(2.0); + static TANK_DEFAULT_SPAWN_X = new Constants(4*this.TILE_SIZE.getValue()); + static TANK_DEFAULT_SPAWN_Y = new Constants(12*this.TILE_SIZE.getValue()); + static SHOT_SPEED = new Constants(2.0); static SHOT_SIZE = new Constants(5);