Proposal Reviews
In-class review of proposals.
Multiple Scene Code Example
// Three_Act.pde
// Example code that shows how set up a sketch that has multiple scenes/acts/stages
// 1. declare a variable to remember what scene we are on
// 2. create a seperate function responsible for drawing each scene
// 2. in draw() use if/else to call the function for the current scene
//
// Class: PUDT1203
// Author: Justin Bakse
int currentAct = 1;
void setup() {
size(625, 350);
}
void draw() {
// use currentAct variable to determine which act to draw, call the funcitn that draws it
if (currentAct == 1) {
drawAct1();
}
else if (currentAct == 2) {
drawAct2();
}
else if (currentAct == 3) {
drawAct3();
}
}
void drawAct1() {
//draw scene
background(200, 100, 100);
textSize(32);
textAlign(CENTER, BOTTOM);
fill(100, 200, 200);
text("ACT ONE", width * .5, height * .5);
//draw button
rect(200, 200, 25, 25);
//if the mouse is down on the button, set currentAct's value to the number of the act we want to start drawing
if (mousePressed && mouseX > 200 && mouseX < 225 && mouseY > 200 && mouseY < 225) {
currentAct = 2;
}
}
void drawAct2() {
background(100, 200, 100);
textSize(32);
textAlign(CENTER, BOTTOM);
fill(200, 100, 200);
text("ACT TWO", width * .5, height * .5);
rect(300, 200, 25, 25);
if (mousePressed && mouseX > 300 && mouseX < 325 && mouseY > 200 && mouseY < 225) {
currentAct = 3;
}
}
void drawAct3() {
background(100, 100, 200);
textSize(32);
textAlign(CENTER, BOTTOM);
fill(200, 200, 100);
text("ACT THREE", width * .5, height * .5);
rect(400, 200, 25, 25);
if (mousePressed && mouseX > 400 && mouseX < 425 && mouseY > 200 && mouseY < 225) {
currentAct = 1;
}
}
Homework
Next week is the project crit. All three acts of your work should be working.