Hi ! So, I’m trying to make a game for a school project and I’ve only made a menu so far, anyway I’d like some help on switching from the menu screen to the game screen. Right now, when I click on my button, nothing really happens( except that it won’t change color anymore I d’ont know why), basically, what I did was declaring an integer called Screen, I’d give it the value 0 and in the draw , in the draw if screen’s value is 0, then it displays the menu, if it’s one, it should display the game. So I made it so that when clicked on the button, screen changes to 1. But nothing happens.
Sorry there’s some french in my code but can you help me? Thank you! and sorry for my English.
/**********VARIABLES**********/
//musique
import ddf.minim.*;
Minim file;
AudioPlayer mainTheme;
//différents écrans
int screen = 0;
//variables bouton
color boutonColorClique = color(255,255,255,255);
float wBoutonStart = 500;
float hBoutonStart = 250;
//image fond menu
PImage fondMenu;
/**********SETUP**********/
void setup() {
//universel
fullScreen();
noStroke();
noFill();
//menu seulement
fondMenu = loadImage("fondMenu.jpg");
mainSong();
}
/**********DRAW**********/
void draw() {
if (screen == 0){
menuScreen();
} else if (screen == 1){
gameScreen();
}
}
/**********DIFFERENTS ECRANS**********/
void menuScreen(){
image(fondMenu, 0, 0,width,height);
texteMenu();
carreBouton();
overBouton();
}
void gameScreen(){
fill(255);
}
/**********AUTRES VOIDS**********/
void mainSong(){
file = new Minim(this);
mainTheme = file.loadFile("mainTheme.wav");
mainTheme.play();
}
void carreBouton() {
rectMode(CENTER);
fill(0,0,0,0);
rect(width/2,height/2,wBoutonStart,hBoutonStart,40);
}
void texteMenu(){
fill(boutonColorClique);
textAlign(CENTER);
textSize(50);
text("START",width/2,height/2);
fill(255);
textSize(200);
text("Horilonia", width/2, height/4 +100);
}
void overBouton(){
if(mouseX>width/2-wBoutonStart/2 && mouseX <width/2+wBoutonStart/2 && mouseY>height/2-hBoutonStart/2 && mouseY <height/2+hBoutonStart/2 && mousePressed){
boutonColorClique = color(255,255,255,100);
screen = 1;
}
}