Major rework of basic game code - pre-work for multiplayer
Includes automatic generation of required HTML elements and better responsiveness
This commit is contained in:
20
js/player.js
20
js/player.js
@@ -6,9 +6,8 @@ class Player {
|
||||
this.pos = {x: 0, y: 0};
|
||||
this.matrix = null;
|
||||
this.score = 0;
|
||||
|
||||
this.isHolding = false;
|
||||
this.holdingTile = null;
|
||||
this.level = 1;
|
||||
this.lastLevelScore = 0;
|
||||
|
||||
this.a.p = this;
|
||||
}
|
||||
@@ -29,19 +28,6 @@ class Player {
|
||||
this.g.dropCounter = 0;
|
||||
}
|
||||
|
||||
hold() {
|
||||
if (this.isHolding)
|
||||
return;
|
||||
if (this.holdingTile === null) {
|
||||
this.holdingTile = this.matrix;
|
||||
this.reset(true);
|
||||
} else {
|
||||
this.holdingTile = [this.matrix, this.matrix = this.holdingTile][0];
|
||||
this.reset(true, false);
|
||||
}
|
||||
this.game.drawHolding();
|
||||
}
|
||||
|
||||
move(dir) {
|
||||
this.pos.x += dir;
|
||||
if (collide(this.a.field, this)) {
|
||||
@@ -83,4 +69,4 @@ class Player {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user