Jump to content

Tetris/Java: Difference between revisions

m
each Shape should just have one shape
mNo edit summary
m (each Shape should just have one shape)
Line 214:
g.translate(offsetX, offsetY);
 
for (int[] p : preSelectedShape.shapes[idx]shape)
drawSquare(g, idx, p[1], p[0]);
 
Line 457:
 
enum Shape {
ZShape(new int[][]{{0, SShape-1}, Straight{0, TShape0}, Square{-1, LShape0}, JShape;{-1, 1}}),
SShape(new int[][]{{0, -1}, {0, 0}, {1, 0}, {1, 1}}),
Straight(new int[][]{{0, -1}, {0, 0}, {0, 1}, {0, 2}}),
TShape(new int[][]{{-1, 0}, {0, 0}, {1, 0}, {0, 1}}),
Square(new int[][]{{0, 0}, {1, 0}, {0, 1}, {1, 1}}),
LShape(new int[][]{{-1, -1}, {0, -1}, {0, 0}, {0, 1}}),
JShape(new int[][]{{1, -1}, {0, -1}, {0, 0}, {0, 1}}});
 
private Shape(int[][] shape) {
this.shape = shape;
pos = new int[4][2];
reset();
Line 466 ⟶ 473:
void reset() {
for (int i = 0; i < pos.length; i++) {
pos[i] = shapes[ordinal()]shape[i].clone();
}
}
 
final int[][] pos, shape;
 
final int[][][] shapes = {
{{0, -1}, {0, 0}, {-1, 0}, {-1, 1}},
{{0, -1}, {0, 0}, {1, 0}, {1, 1}},
{{0, -1}, {0, 0}, {0, 1}, {0, 2}},
{{-1, 0}, {0, 0}, {1, 0}, {0, 1}},
{{0, 0}, {1, 0}, {0, 1}, {1, 1}},
{{-1, -1}, {0, -1}, {0, 0}, {0, 1}},
{{1, -1}, {0, -1}, {0, 0}, {0, 1}}};
}
 
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.