-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathGUI_buttonPoint.pde
More file actions
78 lines (64 loc) · 1.79 KB
/
Copy pathGUI_buttonPoint.pde
File metadata and controls
78 lines (64 loc) · 1.79 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
74
75
76
77
78
/////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////// /////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////
class button_point {
int ID;
int speed = 20;
int positionX;
int positionY;
int defPosX;
int defPosY;
int movement;
int sizeX = 200;
int sizeY = 30;
public button_point(int tid, int x, int y) {
ID = tid;
positionX = x;
positionY = y;
defPosX = x;
defPosY = y;
}
void setSpeed(int a) {
speed = a;
}
void setPosition(int x, int y) {
positionX = x;
positionY = y;
defPosX = x;
defPosY = y;
}
void display() {
stroke(0, 255, 255, transLO);
strokeWeight(5);
switch(movement) {
case 0:
point(defPosX, defPosY);
break;
case 1:
moveRIGHT();
point(positionX, positionY);
break;
case 2:
moveLEFT();
point(positionX, positionY);
break;
}
strokeWeight(1);
line(positionX, positionY, defPosX, defPosY);
strokeWeight(1);
}
void moveLEFT() {
if (positionX > defPosX-sizeX) {
positionX -=speed;
}
}
void moveRIGHT() {
if (positionX < defPosX+sizeX) {
positionX += speed;
}
}
}