Adapt preview size to shape size

This commit is contained in:
Arnaud Vergnet 2020-07-19 10:43:46 +02:00
parent 4bff6e15a8
commit 1780ab886e
3 changed files with 7 additions and 4 deletions

View file

@ -53,8 +53,6 @@ export default class BaseShape {
/**
* Gets this object's current shape.
*
* Used by tests to read private fields
*/
getCurrentShape(): Shape {
return this.#currentShape;

View file

@ -145,7 +145,7 @@ export default class GameLogic {
callback(this.#gridManager.getCurrentGrid());
}
this.#pressInInterval = setTimeout(() =>
this.movePressedRepeat(false, callback, x, y),
this.movePressedRepeat(false, callback, x, y),
isInitial ? this.#autoRepeatActivationDelay : this.#autoRepeatDelay
);
}
@ -166,7 +166,8 @@ export default class GameLogic {
getNextPiecesPreviews() {
let finalArray = [];
for (let i = 0; i < this.#nextPieces.length; i++) {
finalArray.push(this.#gridManager.getEmptyGrid(4, 4));
const gridSize = this.#nextPieces[i].getCurrentShape().getCurrentShape()[0].length;
finalArray.push(this.#gridManager.getEmptyGrid(gridSize, gridSize));
this.#nextPieces[i].toGrid(finalArray[i], true);
}

View file

@ -165,4 +165,8 @@ export default class Piece {
getCoordinates(): Array<Coordinates> {
return this.#currentShape.getCellsCoordinates(true);
}
getCurrentShape() {
return this.#currentShape;
}
}