Tetris/Java: Difference between revisions
Content added Content deleted
m (add collection template) |
m (→Code: remove dead code) |
||
Line 75: | Line 75: | ||
case KeyEvent.VK_LEFT: |
case KeyEvent.VK_LEFT: |
||
if (canMove(fallingShape, Dir.left)) |
if (canMove(fallingShape, Dir.left)) |
||
move( |
move(Dir.left); |
||
break; |
break; |
||
case KeyEvent.VK_RIGHT: |
case KeyEvent.VK_RIGHT: |
||
if (canMove(fallingShape, Dir.right)) |
if (canMove(fallingShape, Dir.right)) |
||
move( |
move(Dir.right); |
||
break; |
break; |
||
Line 87: | Line 87: | ||
fastDown = true; |
fastDown = true; |
||
while (canMove(fallingShape, Dir.down)) { |
while (canMove(fallingShape, Dir.down)) { |
||
move( |
move(Dir.down); |
||
repaint(); |
repaint(); |
||
} |
} |
||
Line 152: | Line 152: | ||
if (!scoreboard.isGameOver()) { |
if (!scoreboard.isGameOver()) { |
||
if (canMove(fallingShape, Dir.down)) { |
if (canMove(fallingShape, Dir.down)) { |
||
move( |
move(Dir.down); |
||
} else { |
} else { |
||
shapeHasLanded(); |
shapeHasLanded(); |
||
Line 291: | Line 291: | ||
} |
} |
||
void move( |
void move(Dir dir) { |
||
fallingShapeRow += dir.y; |
fallingShapeRow += dir.y; |
||
fallingShapeCol += dir.x; |
fallingShapeCol += dir.x; |