-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTableSquare.pde
More file actions
58 lines (53 loc) · 1.66 KB
/
TableSquare.pde
File metadata and controls
58 lines (53 loc) · 1.66 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
public class TableSquare extends Button
{
public int x,y;
public PeriodicTableElements element;
public boolean isHighLight;
TableSquare(int Y, int X, PImage img, Type _myType, PVector _position, PVector _size, ButtonType type)
{
super(img, _myType, _position, _size, type);
x = X;
y = Y;
}
@ Override
public void DrawButton()
{
if (element == null)
image(imageButton, position.x, position.y, size.x, size.y);
else
image(element.information.myImage, position.x, position.y, size.x, size.y);
if (isHighLight)
{
line(position.x, position.y, position.x + size.x, position.y + size.y);
line(position.x, position.y + size.y, position.x + size.x, position.y);
}
//noFill();
//strokeWeight(24);
//rect(position.x, position.y, size.x, size.y);
}
@ Override
public void isInside(PVector mousePosition)
{
if (mousePosition.x < size.x + position.x && mousePosition.x > position.x)
{
if (mousePosition.y < size.y + position.y && mousePosition.y > position.y)
{
if (element != null && element.playerOne == playerTurnGame)
{
if (manager.selectedPiece == null)
manager.SelectPiece(this);
else if (manager.selectedPiece != null)
manager.MovePiece(element.positionX, element.positionY);
}
else if(element != null && element.playerOne != playerTurnGame)
{
manager.MovePiece(element.positionX, element.positionY);
}
else if(element == null)
{
manager.MovePiece(x,y);
}
}
}
}
}