///move through different screens, some on timers //pressing 'enter' or 'return' increments an int variable called 'scrn' which will define //which 'screen' we see, there is a timer, set to 20 seconds for some screens //for those screens with a timer after 20 seconds the next screen is displayed String info = "Press 'Enter' or 'Return' to advance to next screen"; int scrn = 0; int scrnstart; int scrntime = 20; boolean scrnstarted = false; PImage fibo; PImage screen1; PImage screen1a;//will capture screen PImage screen2; PImage screen2a;//will capture screen PImage screen3; PImage screen3a; //will capture screen PImage screen4; PImage screen4a;//will capture screen PImage screen5; PImage screen5a;//capture PImage screen6; PImage screen6a;//capture PFont font; PImage back; //first image, size of screen void setup () { size (600,400); font = loadFont ("Garamond-48.vlw"); textFont(font, 22); textAlign(CENTER); smooth(); back=loadImage ("back.jpg"); //first image , first backgound image screen1 = createImage (width, height, RGB); //createImage() Creates a new PImage (the datatype for storing images). //This provides a fresh buffer of pixels //we use it to get what is on screen, which we will display as thumbnails at the end fibo = loadImage("fibo.jpg"); screen1 = loadImage("screen1.jpg"); screen1a = createImage (width, height, RGB); //these 'a' images will be like thumbnail sketches screen2 = loadImage ("screen2.jpg"); screen2a = createImage (width, height, RGB); screen3 = loadImage("screen3.jpg"); screen3a = createImage (width, height, RGB); screen4 = loadImage("screen4.jpg"); screen4a = createImage (width, height, RGB); screen5 = loadImage("screen5.jpg"); screen6 = loadImage("screen6.jpg"); } void draw () { background (100); if (scrn == 0) { //screen is defined by the 'scrn' int variable which is incremented if the user presses 'enter' or 'return' key //scrn starts at 0 image (back, 55, 10, 500, 350); //background image image(fibo, 40, 60, 40, 40);//mr fibbonacci fill(0); text ("PRESS ENTER TO SEE NEXT SCREEN", 340, 95); text ("screen o, the program begins, look there's fibbonacci", width/2, 375); } else if (scrn == 1){ image(screen1, 0, 0); image(fibo, 50, 50, 50, 50); text ("This is screen 1", width/2, 35); text ("This screen is not on a timer, but the next one is, press \n 'Enter' to advance to the next screen", width/2, 160); screen1a = get(0,0,width,height); //capture this screen, would make more sense if interactive things were going on } else if (scrn == 2){ if (scrnstarted == false){ //it will be false because pressing 'enter' sets it to false, we got here by //pressing 'enter' scrnstart= millis(); //Returns the number of milliseconds (thousandths of a second) since starting an applet. //This information is often used for timing animation sequences. scrnstarted = true; //start timing } int scrn1current = millis(); //time at this point //calculate remaining time: int timeremaining = scrntime-(scrn1current-scrnstart)/1000; //calculates how long this screen has been runing for //if you dont understand try printing the variables to the console so you can see what is what. //we gave scrntime the value of 20 (at top), but could change it to any length we want image(screen2, 0, 0); text ("You have 20 seconds at look at this screen", width/2, 85); text ("or press \n 'Enter' to advance to the next screen", width/2, 160); text ("This is screen 2", width/2, 35); fill(0); text (timeremaining, 25, 375); //print how much time is left if (timeremaining <= 0){ //and advance when we reach 0 advscrn(); //move to next screen if time is up } screen2a = get(0,0,width,height); } else if (scrn == 3 ){ image(screen3, 0, 0); text ("This is screen 3, it is not on a timer, but could be", width/2, 35); screen3a=get(0,0, width, height); } else if (scrn == 4){ if (scrnstarted == false){ scrnstart= millis(); scrnstarted = true; } int scrn2current = millis(); int timeremaining = scrntime-(scrn2current-scrnstart)/1000; image(screen4, 0, 0); // text (advance, width/2, 375); text ("screen 4, this is on a timer", 220, 35); fill(0); text (timeremaining, 25, 375); if (timeremaining <= 0){ advscrn(); } screen4a = get(0,0,width,height); } else if (scrn == 5){ image(screen5, 0, 0); fill(0, 0, 255); text ("This is screen 5, not timed", width/2, 35); screen5a=get(0,0, width, height); } else if (scrn == 6){ if (scrnstarted == false){ scrnstart= millis(); scrnstarted = true; } int scrn6current = millis(); int timeremaining = scrntime-(scrn6current-scrnstart)/1000; //remember int scrntime = 20 image(screen6, 0, 0); text (info, width/2, 375); text ("screen 6, timed", 90, 35); text (timeremaining, 25, 375); if (timeremaining <= 0){//we have run out of time advscrn(); //move to next screen } screen6a = get(0,0,width,height); //create a PImage from what is on screen } else if (scrn ==7){ //display thumbnails image(screen1a, 5,5, 180, 120); image(screen2a, 5, 140, 180, 120); image(screen3a, 5, 275, 180, 120); image(screen4a, 200, 5, 180, 120); image(screen5a, 200, 140, 180, 120); image(screen6a, 200, 275, 180, 120); text ("Press 'Enter' \n to restart", 500, 330); } } void advscrn(){ scrn++; scrnstarted = false;//stop timer from previous screen } void keyPressed() { if (key == ENTER || key == RETURN) { scrn++; scrnstarted = false; //stop timer if (scrn>7){ scrn =0; //go back to first screen } } }