I've seen alot of example that use keyCoded with "if" statements, right now i'm using switch statements with case and breaks but trying to get it to work with keyCoded. When I have the code run it just runs all the way through it fast instead of breaking it seems.
Here's some of my code if you can figure out what i'm doing wrong...
int number = 0;
PImage img;
PFont font;
void setup() {
size (1000, 800);
background (255);
smooth();
println(number);
keyCode = UP;
}
void draw() {
smooth();
switch(number) {
case 0:
font = loadFont("Times-Roman-22.vlw");
textFont(font);
fill(0);
text("It's the year 2014, you're an average 24 year old living in a small town", 100, 50);
text("in Ohio. You find yourself in a low wage job, living in a small apartment with", 100, 100);
text("your fiance. You have had little education past high school and your life has become", 100, 150);
text("rather dull. You have a tradition of buying a lottery ticket every week and it just", 100, 200);
text("so happens to be your lucky day! You’ve won $15 million dollars! What do you do next?", 100, 250);
text("To continue click the right arrow key.", 100, 400);
if (key == CODED) {
if (keyCode == RIGHT) {
number = 1;
}
}
break;
case 1:
img = loadImage ("white.jpg");
image (img, 0, 0);
font = loadFont("Times-Roman-22.vlw");
textFont(font);
fill(0);
text("You first wonder if there's any need to keep your job. Do you quit? Or Stay?", 150, 50);
text("To quit click the left arrow key. To keep your job click the right arrow key.", 150, 700);
if (key == CODED) {
if (keyCode == LEFT) {
number = 2;
}
if (keyCode == RIGHT) {
number = 3;
}
}
break;
Thanks!
Here's some of my code if you can figure out what i'm doing wrong...
int number = 0;
PImage img;
PFont font;
void setup() {
size (1000, 800);
background (255);
smooth();
println(number);
keyCode = UP;
}
void draw() {
smooth();
switch(number) {
case 0:
font = loadFont("Times-Roman-22.vlw");
textFont(font);
fill(0);
text("It's the year 2014, you're an average 24 year old living in a small town", 100, 50);
text("in Ohio. You find yourself in a low wage job, living in a small apartment with", 100, 100);
text("your fiance. You have had little education past high school and your life has become", 100, 150);
text("rather dull. You have a tradition of buying a lottery ticket every week and it just", 100, 200);
text("so happens to be your lucky day! You’ve won $15 million dollars! What do you do next?", 100, 250);
text("To continue click the right arrow key.", 100, 400);
if (key == CODED) {
if (keyCode == RIGHT) {
number = 1;
}
}
break;
case 1:
img = loadImage ("white.jpg");
image (img, 0, 0);
font = loadFont("Times-Roman-22.vlw");
textFont(font);
fill(0);
text("You first wonder if there's any need to keep your job. Do you quit? Or Stay?", 150, 50);
text("To quit click the left arrow key. To keep your job click the right arrow key.", 150, 700);
if (key == CODED) {
if (keyCode == LEFT) {
number = 2;
}
if (keyCode == RIGHT) {
number = 3;
}
}
break;
Thanks!
1