@DijaAngel I answered in the other discussion.
Hello and welcome to the forum!
Great to have you here!
You can merge the two sketches when you use a “state” variable. This state tells you whether to show the menu or the game (or other screens, like a Splash Screen or a help screen. Even the Game with 2 players versus the Game against the computer can be seen as two different states.)
Warm regards,
Chrisir
Here is an Example for state, menu and game:
//
final int MENU=0; // state and the values (constants) state can have; must be unique numbers
final int GAME=1;
int state = MENU;
float x = 100;
float y = 50;
float w = 150;
float h = 80;
void setup() {
size(500, 500);
background(255);
stroke(0);
noFill();
}
void draw() {
background(255);
switch (state) {
case MENU:
// step 1: draw the button rect with a fill color differently when mouse is upon it or not
fill(255); // color when NOT over
if (mouseOverButton1()) {
fill(255, 255, 0); // when over
}
rect(x, y, w, h); // rect
//------------------
// step 2 : show text
fill(0);
text ("CLICK", x+17, y+28); // put something here like: 2 Players OR Player vs. AI
break;
case GAME:
fill(0); // here goes your PONG Game !!!!!!!!!!!!!
text ("IMPLEMENT Game here ",
117, y+128);
break;
//
}//switch
//
}//func
// ------------------------------------------------------------------------
void mousePressed() {
// step 3: check mouse clicked // This is when mouse has been clicked
if (mousePressed) {
if (mouseOverButton1()) {
// println("The mouse is pressed and over the button");
state = GAME;
fill(0);
//do stuff
}
}
}
boolean mouseOverButton1() { // This is for button number 1
return
mouseX>x &&
mouseX <x+w &&
mouseY>y &&
mouseY <y+h;
}
//