How do I make a sketch window open, when a piece of txt has been clicked on in a previous window?
in
Programming Questions
•
2 years ago
Hi All
I have a small problem. I have made a processing program that when run comes up with a menu window. The code for this program is:
int x = 125;
int y = 235;
int y = 235;
PFont font;
void setup(){
size(400,400);
smooth();
font = loadFont("LucidaConsole-26.vlw");
textFont(font);
}
size(400,400);
smooth();
font = loadFont("LucidaConsole-26.vlw");
textFont(font);
}
void draw(){
background(0);
textSize (26);
fill (105,255,98);
textAlign(CENTER);
text("Welcome to Pong!",width/2,35);
textSize(26);
text("Start Game",width/2,150);
textSize(26);
rectMode(CENTER);
text("Quit Game",200,225,150,26);
background(0);
textSize (26);
fill (105,255,98);
textAlign(CENTER);
text("Welcome to Pong!",width/2,35);
textSize(26);
text("Start Game",width/2,150);
textSize(26);
rectMode(CENTER);
text("Quit Game",200,225,150,26);
if ((mousePressed) && (mouseX > x) && (mouseX < 270) &&
(mouseY < y) && (mouseY > 210)){
exit();
}
}
(mouseY < y) && (mouseY > 210)){
exit();
}
}
I am trying to make the program such that when the mouse is clicked on start game. The user is taken to this window that uses this code:
PFont font;
void setup(){
size(400,400);
smooth();
font = loadFont("LucidaConsole-35.vlw");
textFont(font);
}
size(400,400);
smooth();
font = loadFont("LucidaConsole-35.vlw");
textFont(font);
}
void draw(){
background(0);
textSize (35);
fill (105,255,98);
textAlign(CENTER);
text("Instructions",width/2,35);
textSize(20);
textAlign(LEFT);
text("Use the up/down keys on the keyboard or mouse to control your paddle and stop the ball from going into your goal.\n\nFirst to score 15 is the winner.\n\nClick mouse to start game.",10,50,230,390);
background(0);
textSize (35);
fill (105,255,98);
textAlign(CENTER);
text("Instructions",width/2,35);
textSize(20);
textAlign(LEFT);
text("Use the up/down keys on the keyboard or mouse to control your paddle and stop the ball from going into your goal.\n\nFirst to score 15 is the winner.\n\nClick mouse to start game.",10,50,230,390);
// Keyboard arrow keys icon
//up/down arrow keys
fill(105,255,98);
noStroke();
rect(315,50,35,35);
rect(315,87,35,35);
fill(105,255,98);
noStroke();
rect(315,50,35,35);
rect(315,87,35,35);
fill(0);
triangle(332,52,348,66,317,66);
rect(326,66,13,17);
triangle(332,52,348,66,317,66);
rect(326,66,13,17);
//down arrow
triangle(332,120,317,106,348,106);
rect(326,89,13,17);
triangle(332,120,317,106,348,106);
rect(326,89,13,17);
//Lefft right arrow keys
stroke(105,255,98);
rect(277,87,34,34);
rect(353,87,34,34);
rect(277,87,34,34);
rect(353,87,34,34);
fill(105,255,98);
noStroke();
noStroke();
triangle(279,104,296,89,296,119);//left arrow
rect(296,94,13,20);
rect(296,94,13,20);
triangle(385,104,370,119,370,89);//right arrow
rect(357,94,13,20);
rect(357,94,13,20);
//mouse direction
//mouse up arrow
noFill();
stroke(105,255,98);
triangle(332,150,317,164,348,164);
rect(326,164,13,20);
noFill();
stroke(105,255,98);
triangle(332,150,317,164,348,164);
rect(326,164,13,20);
//mouse icon
rect(317,189,32,25);
line(333,189,333,214);
arc(333,214,32,45,0,PI);
rect(317,189,32,25);
line(333,189,333,214);
arc(333,214,32,45,0,PI);
//mouse down arrow
triangle(332,276,317,262,348,262);
rect(326,242,13,20);
}
triangle(332,276,317,262,348,262);
rect(326,242,13,20);
}
Does anyone know what code I need to create the link between the two sketch file such that it seems like one program? Any help would be great! :)
1