mardi 6 octobre 2020

Clueless abour how to use switch

this is my very first post :)

I'm a graphic design student in my second year and we have to make code for business cards. What I want is when I click with my mouse the background of the business card will change.

It worked with a boolean for two pictures. But I now want to have four images.

Have asked the teacher for help and she sent me information about Switch.

But I have no idea where to put in my code and how to fill it in.

This is my code so far

String Instagram="@Famoys_Saz";
String quote = "Guess my passion ;)";
PFont font;
PImage bg;
PImage Snake2;
PImage snake3;
PImage snake4;
boolean click = true; 



void setup() {
  size(850, 550);
  font = createFont("Galaxyfaceano-4yM9.ttf", 45);
  textFont(font);
  textAlign(CENTER);
  bg = loadImage("Snake.jpg");
  Snake2= loadImage ("Snake2.jpg");
  click = true;
}
void draw() {
  background(bg);
  if (click == true ) {
    image(bg, 0, 0);
  } else {  
    image(Snake2, 0, 0);
  }

  text(Instagram, mouseX, mouseY);
  text(quote, mouseY, mouseX, 05);
}

void mousePressed() {

  click =! click;
}

and this is the code my teacher send me:

if( imageNumber == 1 ) {
 
} else if ( imageNumber == 2 ) {
 
} else {

}

Could someone help me out? I'm quite a beginner when it comes to coding.

Aucun commentaire:

Enregistrer un commentaire