-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTetrisGame.java
More file actions
61 lines (54 loc) · 1.25 KB
/
TetrisGame.java
File metadata and controls
61 lines (54 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/**
* This class in connecting the board and the controller
*
* @author Ching Ching Huang
*
*/
public class TetrisGame {
//all the movings
public static final int RIGHT = 1;
public static final int LEFT = 2;
public static final int DOWN = 3;
public static final int CW = 4;
public static final int CCW = 5;
public static final int SPACE_DROP = 6;
//the tetris board
private TetrisBoard tetrisBoard;
/*
* constructor initializes the board
*/
public TetrisGame(){
tetrisBoard = new TetrisBoard();
}
public void attemptMove(int moveType){
//pairing each number with each move
if(moveType == RIGHT){
tetrisBoard.moveRight();
}else if(moveType == LEFT){
tetrisBoard.moveLeft();
}else if(moveType == DOWN){
tetrisBoard.moveDown();
}else if(moveType == CW){
tetrisBoard.rotateCW();
}else if(moveType == CCW){
tetrisBoard.rotateCCW();
}else if(moveType == SPACE_DROP){
tetrisBoard.spaceDrop();
}
}
/*
* getter method for the board
*/
public TetrisBoard getTetrisBoard(){
return tetrisBoard;
}
public int getTetrises(){
return tetrisBoard.getFourLineScore();
}
public int getScore(){
return tetrisBoard.numberOfFormedLines();
}
public int getLevel(){
return tetrisBoard.getLevel();
}
}