-
Notifications
You must be signed in to change notification settings - Fork 0
/
StartPage.pde
57 lines (50 loc) · 1.05 KB
/
StartPage.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
class StartPage{
float btnX,btnY;
int btnWidth,btnHeight;
PImage main;
float txtAlpha;
float speed;
boolean flag;
StartPage(){
btnX=width/2;
btnY=height/1.2;
btnWidth=70;
btnHeight=50;
txtAlpha=255;
speed=5;
flag=false;
main=loadImage("img/main.png");
}
boolean drawStart(){
//draw main image
image(main,0,0);
txtBlinking();
fill(255,txtAlpha);
text("Go !",btnX,btnY);
rectMode(CORNER);
if(btnClicked()) return true;
return false;
}
boolean btnClicked(){
if(mouseClickFlag &&btnX-btnWidth/2<=mouseX && mouseX <=btnX+btnWidth/2 && btnY-btnHeight/2<=mouseY && mouseY<=btnY+btnHeight/2){
mouseClickFlag=false;
return true;
}
return false;
}
void txtBlinking(){
if(!flag){ // alpha goes down
txtAlpha-=speed;
if(txtAlpha<=0){
txtAlpha=0;
flag=true;
}
}else{
txtAlpha+=speed;
if(txtAlpha>=255){
txtAlpha=255;
flag=false;
}
}
}
}