-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTBlock.java
40 lines (37 loc) · 1.42 KB
/
TBlock.java
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
import java.awt.*;
import java.util.HashSet;
import java.util.Set;
public class TBlock extends Block {
public TBlock(Point generatePoint) {
super(generatePoint);
this.points = getPointByState(0);
}
@Override
public Set<Point> getPointByState(int state) {
int x = benchmark.x;
int y = benchmark.y;
Set<Point> points = new HashSet<>();
if (state == 0) {
points.add(new Point(x - BLOCK_SIZE, y - BLOCK_SIZE));
points.add(new Point(x, y - BLOCK_SIZE));
points.add(new Point(x + BLOCK_SIZE, y - BLOCK_SIZE));
points.add(new Point(x, y));
} else if (state == 1) {
points.add(new Point(x - BLOCK_SIZE, y - BLOCK_SIZE));
points.add(new Point(x - BLOCK_SIZE, y));
points.add(new Point(x - BLOCK_SIZE, y + BLOCK_SIZE));
points.add(new Point(x, y));
} else if (state == 2) {
points.add(new Point(x, y));
points.add(new Point(x, y + BLOCK_SIZE));
points.add(new Point(x - BLOCK_SIZE, y + BLOCK_SIZE));
points.add(new Point(x + BLOCK_SIZE, y + BLOCK_SIZE));
} else {
points.add(new Point(x, y));
points.add(new Point(x + BLOCK_SIZE, y - BLOCK_SIZE));
points.add(new Point(x + BLOCK_SIZE, y));
points.add(new Point(x + BLOCK_SIZE, y + BLOCK_SIZE));
}
return points;
}
}