/* Matt Martell IAT 800 - Dr. Christopher Shaw Due Sept. 24, 2008 Project 1 - Clock */ int x=1; //used to calibrate beating heart float a; //used to calculate rotation of arm int z; //used a place holder for counting apples int xPosM = 0; //defines position of apples int yPosM = 110; //defines position of apples int y; //used a place holder for counting pies int xPosH; //defines position of apple_pie int yPosH = 270; //defines position of apple_pie void setup() { size(1100,400); frameRate(2); } void draw() { background(255); int s = second(); int m = minute(); int h = hour(); //Title PImage title; title = loadImage("data/counter_text.png"); image(title, 355,35,360,61); //Directions PImage directions; directions = loadImage("data/directions.png"); image(directions, 750,110,345,149); //The Pirate PImage pirate; pirate = loadImage("data/pirate_no_arm.png"); image(pirate, 35,50,200,300); //Source of Apples PImage apple; apple = loadImage("data/apple.jpg"); image (apple,115,20, 60,60); //Beating Heart to show his love. if(x==1) { PImage heart2; heart2 = loadImage("data/beatingheart2.png"); image(heart2, 150,195, 35,27); x= x+1; } else { PImage heart; heart= loadImage("data/beatingheart.png"); image(heart, 150,195,35,27); x=1; } // Apples reprsent minutes from actual clock (thanks to Shannon Coates for better // looking code than I was coming up with for adding the apples in multiple lines) for (z = 0; z <= 59; z = z + 1) { if (z < m && z < 15) { xPosM = (25 * z) + 350; image(apple, xPosM, yPosM, 20, 20); } if (z <= m && z > 15 && z <= 30){ xPosM = (25 * z)-50; image(apple, xPosM, yPosM + 25, 20, 20); } if (z <= m && z > 30 && z <= 45){ xPosM = (25 * z)-425; image(apple, xPosM, yPosM + 50, 20, 20); } if (z <= m && z>45 && z <= 60){ xPosM = (25 * z) - 800; image(apple, xPosM, yPosM + 75, 20, 20); } } //Pies represent hours from actual clock. It takes 60 Apples to make a pie. PImage apple_pie = loadImage("data/apple_pie.jpg"); for (y = 0; y <= 59; y = y + 1) { if (y < h && y < 12) { xPosH = (65 * y)+ 300; image(apple_pie, xPosH, yPosH, 60, 60); } if (y <= h && y>12 && y <= 24){ xPosH = (65 * y) - 545; image(apple_pie, xPosH, yPosH + 75, 60, 60); } } // Moving arm to represent seconds on the clock { PImage arm; arm = loadImage("data/piratearm.png"); translate(178,195); rotate(radians(a)); image (arm,0,0); a=(s*6-104); // 104 is used to correct the angle of arm to match if (a>361) a=0; } }