Some question about how to do: "press to start (and sound in background)"
in
Programming Questions
•
8 months ago
Good evening to all.
I've realized a simple game in which some viruses fall down, and the Avira umbrella have to repulse them.
I wanted to add a screen before starting the game, in which I wanted to write something like: "Alert, some viruses wants to infect your pc, press SPACE to repulse them" with an alert sound in background, and after pressing space, the game begins.
Could someone please suggest me how to do this?
The code is this:
I've realized a simple game in which some viruses fall down, and the Avira umbrella have to repulse them.
I wanted to add a screen before starting the game, in which I wanted to write something like: "Alert, some viruses wants to infect your pc, press SPACE to repulse them" with an alert sound in background, and after pressing space, the game begins.
Could someone please suggest me how to do this?
The code is this:
- PImage umbrella;
PImage virus;
PImage desktop;
float posXvirus;
float posYvirus;
float PosYumb;
int comincia;
int continua;
int infezione;
int vittoria;
PFont font;
void setup(){
size(1280,720);
desktop = loadImage("steam5.jpg");
umbrella = loadImage("avira.png");
virus = loadImage("virus.gif");
comincia=1;
continua=1;
PosYumb=560;
infezione=0;
vittoria=0;
}
void draw(){
background(desktop);
text("virus sconfitti:", 800, 30);
text("infezioni:", 800, 60);
text(vittoria, 1000, 30);
text(infezione, 1000, 60);
image (virus,posXvirus,posYvirus);
image (umbrella, mouseX, 560);
noCursor();
if (comincia==1)
{
posXvirus=random(width);
posYvirus=0;
comincia=0;
}
else
{
if (continua==1)
{
posYvirus=posYvirus+10;
if(mouseX-50<posXvirus && mouseX>posXvirus && PosYumb-80<posYvirus && PosYumb>posYvirus)
{
continua=0;
vittoria=vittoria+1;
}
else
{
if(posYvirus==PosYumb-10){
infezione=infezione+1;
comincia=1;
}
}
}
else{
posYvirus=posYvirus-20;
if(posYvirus<0){
comincia=1;
continua=1;
}
}
}
}
1