-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUtil.java
More file actions
51 lines (41 loc) · 1.22 KB
/
Copy pathUtil.java
File metadata and controls
51 lines (41 loc) · 1.22 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
package util;
import data.Game;
import objects.Chess;
import java.awt.*;
import java.util.ArrayList;
public class Util {
public static int[][] getChessPositionArray(ArrayList<Chess> chess) {
int[][] chessPositionArray = new int[15][15];
for (Chess chess1 : chess) {
Color color = chess1.getColor();
if (color.equals(Color.black)) {
chessPositionArray[chess1.row][chess1.column] = 1;
} else if (color.equals(Color.white)) {
chessPositionArray[chess1.row][chess1.column] = -1;
}
}
return chessPositionArray;
}
public static int round(int a) {
if (a > 595) {
return 580;
} else if (a < 0) {
return 0;
}
for (int i = 0; i < 800; i = i + 40) {
if (i <= a && a <= i + 40) {
return i + 20;
}
}
return a;
}
public static Point getPointer() {
return Game.mousePointer;
}
public static Point getPointerAtChessboard() {
Point point = new Point(300, 300);
point.x = round(getPointer().x) / 40 - 1;
point.y = round(getPointer().y) / 40 - 1;
return point;
}
}