Gregory - F

By Gregory Batha
import processing.xml.*; import processing.candy.*; //Greg Batha DESMA 28 Interactivity //exercise F Alphabet book (a-e) (processing 135 export) //A is for Apple: reflects my passion for games by //turning something as cliche as "A is for Apple" //into a game //B is for Bed time: reflects my abnormally constant sleepyness //C is for "cant catch me!" reflects my desire for challenging //myself in life and in games (although this challenge is impossible) //D is for Don't push this button: reflects my obsession //with web technology and my desire to create it //E is for etch-a-sketch: goes back to my childhood. It's even //as frustrating to use here as I remember it being back then //mode defines what the program will run //it is defined by the key pressed int mode = 0; //creates the two font sizes PFont size18; PFont size60; //initializes the variables for backgrounds boolean bgIsDrawn = false; PImage bg1; PImage asleep; PImage awake; PImage button; PImage bgImage; //declares the variable for the tack graphic SVG tack; //declaress variables for apple int timer = 0; int numFrames = 30; int frame = 0; PImage[] apple = new PImage[numFrames]; //creates variables for the etch a sketch point int eX = 200; int eY = 200; //declares smiley face and raspberry face SVG smiley; SVG raspberry; //declares pop-up graphic PImage popup; //page D: did they press the button? boolean buttonWasPressed; //declares the smiley's location variables for C float mX; float mY; void setup() { //loads images to be used as backgrounds bg1 = loadImage("square-etch-a-sketch.jpg"); asleep = loadImage("asleep.png"); awake = loadImage("awake.png"); button = loadImage("button.png"); size(400, 400); frameRate(60); //loads two font sizes size18 = loadFont("ArialHebrew-18.vlw"); size60 = loadFont("AbadiMT-CondensedExtraBold-60.vlw"); smooth(); //loads smiley face and raspberry face smiley = new SVG(this, "smiley.svg"); raspberry = new SVG(this, "raspberry.svg"); //creates tack svg tack = new SVG(this, "tack.svg"); //loads pop-up image popup = loadImage("popup.png"); //checks if button was pressed buttonWasPressed = false; //loads all frames for the apple game apple[0] = loadImage("IMG_2665.jpg"); apple[1] = loadImage("IMG_2667.jpg"); apple[2] = loadImage("IMG_2675.jpg"); apple[3] = loadImage("IMG_2686.jpg"); apple[4] = loadImage("IMG_2688.jpg"); apple[5] = loadImage("IMG_2694.jpg"); apple[6] = loadImage("IMG_2699.jpg"); apple[7] = loadImage("IMG_2711.jpg"); apple[8] = loadImage("IMG_2713.jpg"); apple[9] = loadImage("IMG_2719.jpg"); apple[10] = loadImage("IMG_2723.jpg"); apple[11] = loadImage("IMG_2725.jpg"); apple[12] = loadImage("IMG_2726.jpg"); apple[13] = loadImage("IMG_2727.jpg"); apple[14] = loadImage("IMG_2748.jpg"); apple[15] = loadImage("IMG_2756.jpg"); apple[16] = loadImage("IMG_2758.jpg"); apple[17] = loadImage("IMG_2759.jpg"); apple[18] = loadImage("IMG_2761.jpg"); apple[19] = loadImage("IMG_2762.jpg"); apple[20] = loadImage("IMG_2767.jpg"); apple[21] = loadImage("IMG_2785.jpg"); apple[22] = loadImage("IMG_2788.jpg"); apple[23] = loadImage("IMG_2789.jpg"); apple[24] = loadImage("IMG_2808.jpg"); apple[25] = loadImage("IMG_2810.jpg"); apple[26] = loadImage("IMG_2812.jpg"); apple[27] = loadImage("IMG_2813.jpg"); apple[28] = loadImage("IMG_2815.jpg"); apple[29] = loadImage("IMG_2824.jpg"); } //cover page void drawStart() { textFont(size60); fill(0); text("Alphabet book", 14, 60); textFont(size18); text("Welcome to Gregs alphabet book!", 20, 100); text("press keys A-E to turn to the desired page", 30, 160); text("you can always turn back to a page", 20, 300); text("by pressing its respective key again", 30, 330); } //code for "A" page void drawA() { if (bgIsDrawn == false) { bgIsDrawn = true; } //resets the background for the sake of animated text background(0); //prints the text fill(230); textFont(size60); text("A", 14, 48); textFont(size18); text("is for", 70, 39); text("rapidly click the mouse to devour!", 5, 395); textFont(size60); text("Apple!", 130, 48); //prints the timer if(timer > 60*10) {text(0, 330, 395);} else if(timer > 60*9) {text(1, 330, 395);} else if(timer > 60*8) {text(2, 330, 395);} else if(timer > 60*7) {text(3, 330, 395);} else if(timer > 60*6) {text(4, 330, 395);} else if(timer > 60*5) {text(5, 330, 395);} else if(timer > 60*4) {text(6, 330, 395);} else if(timer > 60*3) {text(7, 330, 395);} else if(timer > 60*2) {text(8, 330, 395);} else if(timer > 60) {text(9, 330, 395);} else if(timer <= 60) {text(10, 330, 395);} //draws image if time hasn't run out if(timer > 60*10 && frame < 30) { textFont(size60); fill(255, 0, 0); text("YOU LOSE", 80, 200); } //if there's still time, draws latest frame else { if(frame < 28) {image(apple[frame], 0, 67);} //if the user has one, then only the last frame is printed //along with a congratulatory message else { image(apple[29], 0, 67); textFont(size18); text("GREAT JOB!", 245, 140); } } //increments timer every frame timer++; } //code for "B" page void drawB() { if (bgIsDrawn == false) { background(asleep); bgImage = asleep; bgIsDrawn = true; } if(mouseX>19 && mouseX<117 && mouseY>98 && mouseY<200 && mousePressed == true) { background(awake); bgImage = awake; } background(bgImage); tack.draw(mouseX, mouseY-54); fill(0); textFont(size60); text("B", 14, 48); textFont(size18); text("is for Bed time", 20, 390); } //code for "C" page void drawC() { mX = mouseX+75; mY = mouseY-75; float velocity = dist(pmouseX, pmouseY, mouseX, mouseY); //checks the location of the face to make sure //it doesn't go out of bounds if(mX > 350) { mX=350; mY++; } if(mY < 0) { mY = 0; mX--; } if(mouseX > 330) { mX = mouseX-100; mY = mouseY+50; } if(mY > 350) { mY = 350; } //if you move too fast, face laughs at you if(velocity > 1) { background(204); raspberry.draw(mX, mY); } else { background(200); smiley.draw(mX, mY); } //writes the text fill(30); textFont(size60); text("C", 14, 48); textFont(size18); text("is for 'can't catch me!'", 20, 390); } //code for "D" page void drawD() { //draws the button background once if (bgIsDrawn == false) { background(button); bgIsDrawn = true; } //if they haven't pressed the button yet, print text if(buttonWasPressed == false) { fill(30); textFont(size60); text("D", 14, 48); textFont(size18); text("is for", 55, 45); textFont(size18); fill(255); text("DO NOT push", 145, 190); text("this button", 155, 215); } //if you press the button. if(mouseX > 110 && mouseX < 285 && mouseY > 112 && mouseY < 286 && mousePressed == true) { //forloop creates a popup every 1/6 second for(int i = 0; i<= 5; i++) { image(popup, random(168), random(256)); } buttonWasPressed = true; } } //code for "E" page void drawE() { fill(230); textFont(size60); text("E", 14, 48); textFont(size18); text("is for", 70, 39); text("use arrow keys to move", 90, 366); text("press E again to clear", 102, 391); stroke(100); //draws the etch-a-sketch background once if (bgIsDrawn == false) { background(bg1); bgIsDrawn = true; } //assures that the point doesn't leave the drawing area if(eX < 56) {eX = 56;} else if(eX > 342) {eX = 342;} if(eY < 58) {eY = 58;} else if(eY > 334) {eY = 334;} //draws the point //point location is controlled by eX and eY //eX and eY are controlled by the arrow keys //in the keyPressed function ellipse(eX, eY, 1, 1); } void draw() { if(mode == 0) { drawStart(); } else if(mode == 1) { drawA(); } else if(mode == 2) { drawB(); } else if(mode == 3) { drawC(); } else if(mode == 4) { drawD(); } else if(mode == 5) { drawE(); } } void keyPressed() { if(key == 'a' || key == 'A') { mode = 1; bgIsDrawn = false; timer = 0; frame = 0; } else if(key == 'b' || key == 'B') { mode = 2; bgIsDrawn = false; } else if(key == 'c' || key == 'C') { mode = 3; bgIsDrawn = false; } else if(key == 'd' || key == 'D') { mode = 4; bgIsDrawn = false; buttonWasPressed = false; } else if(key == 'e' || key == 'E') { mode = 5; bgIsDrawn = false; } //changes eX and eY by using the arrow keys if(key == CODED) { if(keyCode == UP) {eY--;} else if(keyCode == DOWN) {eY++;} else if(keyCode == LEFT) {eX--;} else if(keyCode == RIGHT) {eX++;} } } void mousePressed() { frame++; }

2 Comments

  1. Cindy Chi
    Posted October 15, 2008 at 3:47 pm | Permalink

    greg, you’re insane. but a genius. but insane.

  2. Posted October 16, 2008 at 10:49 am | Permalink

    This is full of life and great ideas, but it lacks coherence and attention to visual detail. It’s a great piece, but please consider the visual elements more in the future.

One Trackback

  1. By fjbnheipsssf on January 31, 2009 at 1:31 pm

    fjbnheipsssf…

    Anyway, you should do your best ;)…

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*