Browse Source

Adapt preview size to shape size

Arnaud Vergnet 1 year ago
parent
commit
1780ab886e

+ 0
- 2
src/screens/Game/Shapes/BaseShape.js View File

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

+ 3
- 2
src/screens/Game/logic/GameLogic.js View File

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

+ 4
- 0
src/screens/Game/logic/Piece.js View File

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

Loading…
Cancel
Save