-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStackBrick.java
More file actions
73 lines (67 loc) · 2.21 KB
/
StackBrick.java
File metadata and controls
73 lines (67 loc) · 2.21 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
62
63
64
65
66
67
68
69
70
71
72
73
/*
* Name: Gabriella Toby and Adetola Aladekoba
* Purpose: The source code for the stack brick subclass
* Date: 26/04/2024
*/
public class StackBrick extends TetrisBrick
{
public StackBrick(int center_column)
{
super();
colorNum=5;
this.initPosition(center_column);
}
public void initPosition(int center_column)
{
position = new int[][] {
{center_column,0},
{center_column,1},
{center_column-1,1},
{center_column+1,1},
};
}
public void rotate()
{
int centCol = position[1][0];
int centRow = position[1][1];
if(orientation == 0){
position = new int[][]{ { centCol+1, centRow},
{ centCol, centRow},
{ centCol, centRow-1},
{ centCol, centRow+1},
};
orientation+=1;
}
else if(orientation ==1){
position = new int[][]{ { centCol, centRow+1},
{ centCol, centRow},
{ centCol+1, centRow},
{ centCol-1, centRow},
};
orientation+=1;
}
else if(orientation ==2){
position = new int[][]{ { centCol-1, centRow},
{ centCol, centRow},
{ centCol, centRow+1},
{ centCol, centRow-1},
};
orientation+=1;
}
else if(orientation == 3)
{
position = new int[][]{ { centCol, centRow-1},
{ centCol , centRow},
{ centCol-1, centRow},
{ centCol+1, centRow},
};
orientation=0;
}
}
public void unrotate()
{
rotate();
rotate();
rotate();
}
}