int rx=200; //x coordinate of moving rectangle
String start="start";
String instruct="instructions"
int ry=380;
int l=50;
int w=140;
int sx=140;
int sy=410;
int minX=200;
int maxX=350;
int gamestart=0;
int a = 20;
//int rx2=
String start="start";
String instruct="instructions";
color turquoise= color(105, 247, 203);
color blue= color(78, 153, 242);
color darkblue= color(17, 180, 237);
color orange= color(237, 211, 12);
void setup() {
size(640, 480);
textSize(25);
startbutton();
instructbutton();
}
void draw() {
background(105, 247, 203);
fill(0);
//starting rectangle
rect(200, 430, 140, 50);
//moving rectangle
noStroke();
fill(47, 227, 232);
rect(rx, ry, 140, 50);
println(rx+" "+ry);
rx=rx+3;
if (rx>=width)
rx=0;
if (ry==620) {
rect(a, 20, 20, 20);
a=a+1;
}
mouseClicked();//go to mouseclicked function
}
void instruct() {//function used to show the instructions when the button is clicked
fill(darkblue);
rect(0, 0, width, height);
fill(orange);
textSize(22);
//text
String begin= "Game Instructions";
String line 1=" In Stack it Up, the player the player will attempt to stack";
String line2= "the moving rectangles on top of each other."
String line3= "if the stack and the moving square align, the player will";
String line 4= "receive an extra point.";
String line 5= "if you miss a block, you will have to try again!";
//text position on the screen
text(begin, 50, 50);
text(line1, 50, 80);
text(line2, 50, 110);
text(line3, 50, 140);
text(line4, 50, 170);
text(line5, 50, 190);
mouseClicked();// this refers to the mouseCLick function
void startbutton() {
fill(orange);
rect(sx, sy, 110, 60);
fill(0);
text(start, sx+20, sy+40);//text that's found on the start rectangle
}
void instructbutton() {
fill(255);
rect(sx+180, sy, 110, 60);
fill(0);
text(instruct, rx+180, sy+40);//text on instruction button
}
void mousePressed() {
if (mousePressed==true) {
noLoop();
if (ry<=380) {
fill(turquoise);
rect(200+w, ry, w, l);
fill(blue);
ry=ry+200;
}
}
}