Skip to content

Instantly share code, notes, and snippets.

@chnn
Created April 28, 2014 01:43
Show Gist options
  • Select an option

  • Save chnn/11359880 to your computer and use it in GitHub Desktop.

Select an option

Save chnn/11359880 to your computer and use it in GitHub Desktop.

Your syntax was effeedd up. You need to be OCD like your computer is!

Remember to include parenthesis on if statements:

void roll() {
    spaces += int(random(1, 3));
    if (spaces >= 15) {
        spaces = 15;
    }
}

is correct but

void roll() {
    spaces += int(random(1, 3));
    if (spaces >= 15)
        spaces = 15;
}

is not.

Also where you put whitespace doesn't always matter to the computer, but it's still a good practice to use whitespace consistantly. It makes it easier to spot other erros that do matter when reading your code. So jellyFilledEvent() is chill but jellyFilledEvent () is not.

I think what was breaking your program was a lack of semicolon. I fixed that but I forget exactly where it was.

String s1 = "Yum, no problems here, enjoy!";
String s2 = "Jelly filled! Advance 2";
String s3 = "Unidentified hair in first bite. Return 2";
String s4 = "Mysterious disapperances after friend saw the box. Return 1";
String s5 = "Dropped the box. Return 3";
String s6 = "Stale Donut. Return 1";
String s7 = "Hid box from greedy friends. Advance 1";
String s8 = "Became horribly nauseous from eating too many too quickly. Return 4";
String s9 = "Congratulations! You finished the whole box!";
String s10 = "Hello there. You have a box of 15 donuts.\nYour goal is to consume them all. Challenges will present themselves along the way. Good luck. Press space to roll the die.";
void startEvent() {
text(s10, 30, 30);
}
void jellyFilledEvent() {
text(s2, 30, 30);
text("Press R to eat again", 50, 50);
}
void stayaEvent() {
text(s3, 30, 30);
text("Press R to eat again", 50, 50);
}
void hairEvent() {
text(s3, 30, 30);
text("Press R to eat again", 50, 50);
}
void disappearEvent() {
text(s3, 30, 30);
text("Press R to eat again", 50, 50);
}
void staybEvent() {
text(s3, 30, 30);
text("Press R to eat again", 50, 50);
}
void dropEvent() {
text(s3, 30, 30);
text("Press R to eat again", 50, 50);
}
void hotEvent() {
text(s3, 30, 30);
text("Press R to eat again", 50, 50);
}
void staleEvent() {
text(s3, 30, 30);
text("Press R to eat again", 50, 50);
}
void staycEvent() {
text(s3, 30, 30);
text("Press R to eat again", 50, 50);
}
void hideEvent() {
text(s3, 30, 30);
text("Press R to eat again", 50, 50);
}
void staydEvent() {
text(s3, 30, 30);
text("Press R to eat again", 50, 50);
}
void stayeEvent() {
text(s3, 30, 30);
text("Press R to eat again", 50, 50);
}
void sickEvent() {
text(s3, 30, 30);
text("Press R to eat again", 50, 50);
}
void congratsEvent() {
text(s3, 30, 30);
text("Press R to eat again", 50, 50);
}
void keyPressed() {
if (key == ' ') {
if (spaces == JELLYFILLED) {
spaces = 3;
}
}
if (key == 'r' || key == 'R') {
spaces++;
if (spaces < 15) {
roll();
println(spaces);
}
}
}
void roll() {
spaces += int(random(1, 3));
if (spaces >= 15) {
spaces = 15;
}
}
int START = 1;
int JELLYFILLED = 2;
int STAYA = 3;
int HAIR = 4;
int DISAPPEAR = 5;
int STAYB = 6;
int spaces = 1;
int DROP = 7;
int HOT = 8;
int STALE = 9;
int STAYC = 10;
int HIDE = 11;
int STAYD = 12;
int STAYE= 13;
int SICK = 14;
int CONGRATS = 15;
void setup() {
size(1024, 768);
}
void draw(){
background(137,234,242);
if (spaces == START) {
startEvent();
}
// else if (spaces == JELLYFILLED)
// //winGame();
else {
text("You are here:" + spaces, 20, 100);
}
}
mode.id=processing.mode.java.JavaMode
mode=Java
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment