feat: expand space
This commit is contained in:
@@ -36,6 +36,8 @@ public class Tetris {
|
||||
}
|
||||
|
||||
public static void resetSpace() {
|
||||
if (gravityTask != null) gravityTask.cancel();
|
||||
timer.purge();
|
||||
space = new Space();
|
||||
}
|
||||
|
||||
@@ -54,9 +56,13 @@ public class Tetris {
|
||||
}
|
||||
|
||||
public static void stopGame() {
|
||||
gravityTask.cancel();
|
||||
if (gravityTask != null) gravityTask.cancel();
|
||||
timer.purge();
|
||||
if (ui.getMenuPanel() instanceof ScoreMenu) ((ScoreMenu) Tetris.ui.getMenuPanel()).gameOver();
|
||||
if (ui.getMenuPanel() instanceof ScoreMenu) ((ScoreMenu) ui.getMenuPanel()).gameOver();
|
||||
ui.transferFocus();
|
||||
}
|
||||
|
||||
public static void updateScore(int score) {
|
||||
if (ui.getMenuPanel() instanceof ScoreMenu) ((ScoreMenu) ui.getMenuPanel()).updateScore(score);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package eu.midnightdust.yaytris.game;
|
||||
|
||||
import eu.midnightdust.yaytris.Tetris;
|
||||
import eu.midnightdust.yaytris.ui.ScoreMenu;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.util.*;
|
||||
@@ -15,7 +14,7 @@ public class Space {
|
||||
private int score;
|
||||
|
||||
public Space() {
|
||||
gameMap = new Color[12][7];
|
||||
gameMap = new Color[14][8];
|
||||
nextShape = getNextShape();
|
||||
score = 0;
|
||||
}
|
||||
@@ -75,14 +74,12 @@ public class Space {
|
||||
}
|
||||
for (int completedIndex = 0; completedIndex < completedLines.size(); completedIndex++) { // Remove completed lines
|
||||
int line = completedLines.toArray(new Integer[0])[completedIndex];
|
||||
for (int i = line+completedIndex; i >= 0; i--) {
|
||||
if (i >= getMapHeight()) continue;
|
||||
for (int i = line; i >= 0; i--) {
|
||||
gameMap[i] = (i-1 < 0) ? new Color[gameMap[i].length] : gameMap[i-1];
|
||||
}
|
||||
}
|
||||
this.score += combo;
|
||||
if (Tetris.getUi().getMenuPanel() instanceof ScoreMenu) ((ScoreMenu)Tetris.getUi().getMenuPanel()).updateScore(this.score);
|
||||
//System.out.println(score);
|
||||
Tetris.updateScore(this.score);
|
||||
}
|
||||
|
||||
public Tetromino getCurrentTetromino() {
|
||||
|
||||
@@ -89,7 +89,7 @@ public class Tetromino {
|
||||
}
|
||||
|
||||
public Color[] getLine(int line) {
|
||||
Color[] l = new Color[7];
|
||||
Color[] l = new Color[Tetris.getSpace().getMapWidth()];
|
||||
for (int i = 0; i < l.length; i++) {
|
||||
int relY = line - centerPos.getY();
|
||||
if (relY >= collision.length || relY < 0) continue;
|
||||
|
||||
Reference in New Issue
Block a user