Skip to content

Instantly share code, notes, and snippets.

@slambert
Created October 27, 2015 16:04
Show Gist options
  • Save slambert/256f0ec52b3038e023c2 to your computer and use it in GitHub Desktop.
Save slambert/256f0ec52b3038e023c2 to your computer and use it in GitHub Desktop.
This one works with keypressed states
/* A sketch that has states
Steve Lambert October 27, 2015
v.01
Note: Add your own images
*/
int state;
PImage acapulco;
PImage acapulco2;
PImage tape;
void setup(){
size(720,500);
acapulco = loadImage("acapulco.png"); // Load the image into the program
acapulco2 = loadImage("acapulco2.png");
tape = loadImage("tape.png");
state = 0;
} // end setup
void draw(){
if (mouseX > width/3){
state = 1;
}
if (state == 1){
image(acapulco, 0 , 0, 720, 480);
}
if (state == 2){
image(acapulco2, 0 , 0, 720, 480);
}
if (state == 3){
image(tape, 0 , 0, 720, 480);
}
} // end draw
void keyReleased() {
if (key == '1'){
state = 1;
}
if (key == '2'){
state = 2;
}
if (key == '3'){
state = 3;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment