Skip to content

Instantly share code, notes, and snippets.

@darkwave
Created April 11, 2015 14:57
Show Gist options
  • Save darkwave/9336e2fafdd2837fbcc1 to your computer and use it in GitHub Desktop.
Save darkwave/9336e2fafdd2837fbcc1 to your computer and use it in GitHub Desktop.
Esempio menu multiplo con Processing
int MAIN_MENU = 0;
int ARANCIO = 2;
int VIOLA = 1;
int status = 0;
float posX1; //posizione bottone 1
float posX2;
float posY1; //posizione bottone 2
float posY2;
void setup() {
size(800, 600);
posY1 = height / 2;
posY2 = posY1;
posX1 = width / 4;
posX2 = (width / 4) * 3;
}
void draw() {
if (status == MAIN_MENU) { // Menù Principale
background(0);
text("Menu principale", 20, 20);
ellipse(posX1, posY1, 100, 100);
ellipse(posX2, posY2, 100, 100);
}
if (status == VIOLA) {
background(255, 0, 255);
}
if (status == ARANCIO) {
background(255, 128, 0);
}
}
void mousePressed() {
if (status == MAIN_MENU) {
if (dist(posX1, posY1, mouseX, mouseY) < 50) { //cliccato botton 1
status = 1;
}
if (dist(posX2, posY2, mouseX, mouseY) < 50) { //cliccato botton 2
status = 2;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment