Two questions to ask dealing with my circle game. Pretty much have everything coded but I'm experiencing a crash when I get to my game over screen when it comes to the mouseRelease function. Every time you release the mouse the player moves onto the next level. However, if you come in contact with the black perimeter line the game over screen should appear, but the mouseRelease function is affecting the screen. Any ideas for what to put so the mouseRelease function doesn't affect the game over screen? My other question has to do with the score. How would I get the score from level one to carry over to level two and increase, and then have it carry over from level two to level three? My code is as follows:
int a = 0;
int b = 2;
int c = 3;
int num = 0;
int score = 0;
void setup() {
size(500,500);
smooth();
}
void draw() {
background(120);
switch(num) {
case 0: // Start screen
text("PRESS A KEY ON KEYBOARD TO START",130,250);
if (keyPressed==true) {
num = 1;
a=0;
}
break;
case 1: // Level one
fill(255);
strokeWeight(10);
score = a;
text("Level One", 25, 20);
text("Your score is " + score, 15,40);
ellipse(width/2, height/2,400,400); // white cirlce
fill(0);
ellipse(width/2, height/2,a,a); //black circle
if (a>width) {
a=0;
}
if (mousePressed == true) {
a++;
}
if (a>381) {
num = 5;
}
break;
case 2: // Level two
fill(255);
strokeWeight(5);
//score =
text("Level Two", 25, 20);
//text("Your score is " + score, 15,35);
ellipse(width/2, height/2,250,250); //white circle
fill(0);
ellipse(width/2, height/2,a,a); // Black circle
if (a>width) {
a=0;
}
if (mousePressed == true) {
a+=b;
}
if (a>240) {
num = 5;
}
break;
case 3: //Level three
fill(255);
strokeWeight(2);
//score = a;
text("Level Three", 25, 20);
//text("Your score is " + score, 15,35);
ellipse(width/2, height/2,150,150); // white circle
fill(0);
ellipse(width/2, height/2,a,a); //black circle
if (a>width) {
a=0;
}
if (mousePressed == true) {
a+=c;
}
if (a>141) {
num = 5;
}
break;
case 5: // Game over screen
fill(255);
text("GAMEOVER", 220, 250);
text("Press A Key On Keyboard To Restart", 160, 300);
Okay...so I'm in the process of creating this simple circle game for a class assignment. When you click the mouse a black circle starts to expand. The objective is to expand the black circle as close as one can to the black perimeter line. If one comes in contact with the black perimeter line a game over screen appears. My question revolves around the mouse triggers. I only want the player to be able to press the mouse once and once they release it they move on to case 2 (or the second level) if they haven't touched the perimeter line. Does anyone have suggestions about how I might get this to work? My code is as follows:
int a = 0; int num = 0; int score =0;
void setup() { size(500,500); smooth(); } void draw() { background(120); switch(num) { case 0: text("PRESS A KEY ON KEYBOARD TO START",130,250); if (keyPressed==true) { num = 1; a=0; } break; case 1: fill(255); strokeWeight(10); score = a; text("Your score is " + score, 15,35); ellipse(width/2, height/2,400,400); fill(0); ellipse(width/2, height/2,a,a); if (a>width) { a=0; } if (mousePressed == true) { // Once mouse is released I want the player to move to case 2. a++; } if (a>381) { num = 3; } break;
case 3: fill(255); text("GAMEOVER", 220, 250); text("Press A Key On Keyboard To Restart", 160, 300); if (keyPressed ==true) { num = 0; a=0; } break; } }
I asked a question earlier about how to expand a circle with a mouse click and got very helpful answers. I have another question about how I can get the circle that is expanding to stop when I release my mouse button. I figure I will have to use void mouseReleased () but I want the circle to stay the shape it has expanded to, not return to a small dot.
I am a total beginner at processing and have an assignment to create a simple game for a college multimedia course.
My idea for the game is to create levels where the objective is to expand a small circle so that it matches up with the larger circle that it is placed in the middle of. I am unsure as how to go about making a circle expand and how to incorporate mouse clicks to stop and start the expanding?