Tetris/Java: Difference between revisions
m
→Code: Fixed syntax highlighting.
(→{{header|Java}}: cleaned up code a bit, calculate preview offsets) |
m (→Code: Fixed syntax highlighting.) |
||
(2 intermediate revisions by 2 users not shown) | |||
Line 1:
{{collection|Tetris}}
===Code===
{{works with|java|8}}
<
import java.awt.*;
Line 74 ⟶ 75:
case KeyEvent.VK_LEFT:
if (canMove(fallingShape, Dir.left))
move(
break;
case KeyEvent.VK_RIGHT:
if (canMove(fallingShape, Dir.right))
move(
break;
Line 86 ⟶ 87:
fastDown = true;
while (canMove(fallingShape, Dir.down)) {
move(
repaint();
}
Line 151 ⟶ 152:
if (!scoreboard.isGameOver()) {
if (canMove(fallingShape, Dir.down)) {
move(
} else {
shapeHasLanded();
Line 290 ⟶ 291:
}
void move(
fallingShapeRow += dir.y;
fallingShapeCol += dir.x;
Line 359 ⟶ 360:
});
}
}</
<
class Scoreboard {
Line 468 ⟶ 469:
return score;
}
}</
<
enum Shape {
Line 494 ⟶ 495:
final int[][] pos, shape;
}</
<
import java.awt.*;
Line 537 ⟶ 538:
final static Color gridColor = new Color(0xBECFEA);
final static Color gridBorderColor = new Color(0x7788AA);
}</
|