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