Add default spawn of tank

This commit is contained in:
Nikita Iryupin 2021-06-05 14:50:25 +02:00
parent dad4703ee0
commit 4aa6289f50
4 changed files with 9 additions and 5 deletions

View File

@ -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

View File

@ -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

View File

@ -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);
}

View File

@ -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);