Browse Source

Adapt preview size to shape size

Arnaud Vergnet 3 years ago
parent
commit
1780ab886e

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

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

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

145
                 callback(this.#gridManager.getCurrentGrid());
145
                 callback(this.#gridManager.getCurrentGrid());
146
         }
146
         }
147
         this.#pressInInterval = setTimeout(() =>
147
         this.#pressInInterval = setTimeout(() =>
148
-            this.movePressedRepeat(false, callback, x, y),
148
+                this.movePressedRepeat(false, callback, x, y),
149
             isInitial ? this.#autoRepeatActivationDelay : this.#autoRepeatDelay
149
             isInitial ? this.#autoRepeatActivationDelay : this.#autoRepeatDelay
150
         );
150
         );
151
     }
151
     }
166
     getNextPiecesPreviews() {
166
     getNextPiecesPreviews() {
167
         let finalArray = [];
167
         let finalArray = [];
168
         for (let i = 0; i < this.#nextPieces.length; i++) {
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
             this.#nextPieces[i].toGrid(finalArray[i], true);
171
             this.#nextPieces[i].toGrid(finalArray[i], true);
171
         }
172
         }
172
 
173
 

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

165
     getCoordinates(): Array<Coordinates> {
165
     getCoordinates(): Array<Coordinates> {
166
         return this.#currentShape.getCellsCoordinates(true);
166
         return this.#currentShape.getCellsCoordinates(true);
167
     }
167
     }
168
+
169
+    getCurrentShape() {
170
+        return this.#currentShape;
171
+    }
168
 }
172
 }

Loading…
Cancel
Save