Jump to content

Tetris/Java: Difference between revisions

m
no edit summary
m (change header)
mNo edit summary
Line 5:
import static java.lang.String.format;
import java.util.Arrays;
import java.util.Random;
import javax.swing.*;
 
Line 10 ⟶ 11:
public static final int EMPTY = -1;
public static final int BORDER = -2;
 
int[][] grid;
 
Shape fallingShape;
Line 20 ⟶ 19:
int fallingShapeCol;
 
final int blockSize = Config.blockSize;
final int nRows = Config.nRows;
final int nCols = Config.nCols;
final int topMargin = Config.topMargin;
final int leftMargin = Config.leftMargin;
 
final int[][] grid = new int[nRows][nCols];
 
Thread fallingThread;
final Scoreboard scoreboard = new Scoreboard();
static final Random rand = new Random();
 
public Tetris() {
Line 34 ⟶ 36:
setFocusable(true);
 
scoreboard = new Scoreboard();
grid = new int[nRows][nCols];
initGrid();
selectShape();
Line 100:
fallingShape = preSelectedShape;
Shape[] shapes = Shape.values();
preSelectedShape = shapes[(int) (Mathrand.randomnextInt() * shapes.length)];
if (fallingShape != null)
fallingShape.reset();
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.