-
Notifications
You must be signed in to change notification settings - Fork 0
/
Button.pde
66 lines (62 loc) · 1.17 KB
/
Button.pde
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
class Button
{
float x;
float y;
int xSize;
int ySize;
boolean over = false;
int bevel;
Button(int X, int Y, int XSize, int YSize)
{
x = X;
y = Y;
xSize = XSize;
ySize = YSize;
bevel = width/64;
}
void drawButton()
{
background(bg);
rectMode(CENTER);
if (over())
{
fill(100);
rect(x,y,xSize,ySize,bevel);
}
else
{
fill(155);
rect(x,y,xSize,ySize,bevel);
}
if(bg == 200)
{
fill(0);
}
else
{
fill(255);
}
textAlign(CENTER,CENTER);
textSize(width/32);
text("Play", x, y);
text("Use arrow keys to move paddle up and down", xMid, height*0.8);
textSize(width/16); //UPDATED
text("IMPOSSIBLE PONG", xMid, height*0.2);
}
boolean over()
{
return (mouseX > x-(xSize/2) && mouseX < x+(xSize/2) && //TODO use dist()
mouseY > y-(ySize/2) && mouseY < y+(ySize/2));
}
void checkButton()
{
if(over())
{
rectMode(CENTER);
fill(255);
rect(x,y,xSize,ySize, bevel);
paused = false;
rectMode(CORNER);
}
}
}