44 lines
1.0 KiB
Plaintext
44 lines
1.0 KiB
Plaintext
//Aamrun, 11th July 2022
|
|
|
|
int labelLeft = 100, labelTop = 100, labelWidth = 440, labelHeight = 100;
|
|
|
|
int labelTextLeft = 150, labelTextTop = 150;
|
|
|
|
int buttonLeft = 170, buttonTop = 230, buttonWidth = 300, buttonHeight = 100;
|
|
|
|
boolean hasBeenClicked = false;
|
|
|
|
int clicks = 0;
|
|
|
|
|
|
void setup(){
|
|
size(640,480);
|
|
fill(255);
|
|
rect(labelLeft,labelTop,labelWidth,labelHeight);
|
|
fill(0);
|
|
textSize(30);
|
|
text("There have been no clicks yet",labelTextLeft,labelTextTop);
|
|
fill(#c0c0c0);
|
|
rect(buttonLeft,buttonTop,buttonWidth,buttonHeight);
|
|
fill(0);
|
|
text("Click Me !", buttonLeft + 50,buttonTop + 50);
|
|
}
|
|
|
|
void mousePressed(){
|
|
if(mouseX > buttonLeft && mouseX < buttonLeft + buttonWidth
|
|
&& mouseY > buttonTop && mouseY < buttonTop + buttonHeight){
|
|
hasBeenClicked = true;
|
|
clicks++;
|
|
}
|
|
}
|
|
|
|
void draw(){
|
|
if(hasBeenClicked == true){
|
|
fill(255);
|
|
rect(labelLeft,labelTop,labelWidth,labelHeight);
|
|
fill(0);
|
|
textSize(30);
|
|
text("Clicks : " + str(clicks),labelTextLeft,labelTextTop);
|
|
}
|
|
}
|