Urgent,pleas! I want to add a startscreen into my pong game. Why isn't it working? Thank you.

edited January 2017 in Questions about Code

PImage startscreen; int startscreen; int stage; int base=20; int x,y; int hit = 0; int miss = 0; int changeX=-5; int changeY=-5; int gameOver=0;

void setup(){ stage = 1; startscreen = LoadImage("2teniscourt.jpg"); img(startscreen,0,0,600,600); size(600, 600); x=(int)random(width); y=height-base; } void draw() { if(stage==1){ image(startscreen,600,600); textAlign(CENTER); textSize(45); fill(66, 104, 244); text("PONG GAME",100,170); text("Press any key to start",100,170); if (keyPressed == true){ stage = 2; } }
if (stage == 2){ background(100,200,100); } if(gameOver==0) { background(0); fill(244, 66, 66); text("hit: " + hit,50,40); fill(66, 104, 244); rect(mouseX,height-base,150,base); ellipse(x,y,40,40); x=x+changeX; y=y+changeY; if(x<0 | x>width) { changeX=-changeX; } if(y<0) { changeY=-changeY; } if(y>height-base) { //check if it is falling inside the screen or not if(x>mouseX && x<mouseX+200) { changeY=-changeY; //bounce back hit +=1; } else { gameOverSplash(); } } } else { background(244, 78, 66); fill(66, 104, 244); text("Game Over!",width/2,height/2); text("CLICK MOUSE TO RESTART",width/2,height/2+20); } } void gameOverSplash()
{ gameOver=1; } void mouseClicked() { changeY=-changeY; hit +=1; gameOver=0; }

Tagged:

Answers

This discussion has been closed.