4. Oktober 2012
Fourth Day: A task was given to us over the weekend: We had to create a clock which looks different than the one shown as an example (which happened to be a digital clock). Using the hour(), min() and sec() functions to create a new version of a clock was easier said than done. Thinking of how I could combine a clock with something I like doing during my free time was pretty easy: I love computer games. I took Role-Playing-Games as a inspiration and set my task to mix time with what was essential in RPGs. HP bar meant seconds, MP bar became minutes, EXP bar represented hours and LVL stood for the day of the month. With that, every second that passed would mean progress in the game which can be related to reality.int squaresclr = 0; PImage[] imageList = null; void setup() { imageList = new PImage[1]; imageList[0] = loadImage("./data/GAME.jpg"); size(600, 390); stroke(255); smooth(); } void draw() { background(150); image(imageList[0],0,0); translate(10,20); pushMatrix(); translate(5,0); PFont font; font = loadFont("Arial-Black-48.vlw"); textFont(font, 12); fill(100); String HPStr = ("HP: [" + second() + "/60]"); text(HPStr,0,0); // text("HP",0,0); popMatrix(); pushMatrix(); translate(5,30); font = loadFont("Arial-Black-48.vlw"); textFont(font, 12); fill(100); String MPStr = ("MP: [" + minute() + "/60]"); text(MPStr,0,0); // text("MP",0,0); popMatrix(); pushMatrix(); translate(475,15); font = loadFont("Arial-Black-48.vlw"); textFont(font, 20); fill(100); String LVLStr = ("[LV. " + day() + "]"); text(LVLStr,0,0); popMatrix(); pushMatrix(); translate(5,348); font = loadFont("Arial-Black-48.vlw"); textFont(font, 10); fill(100); String EXPStr = ("EXP [" + hour() + "/24]"); text(EXPStr,0,0); popMatrix(); squaresclr = 0; for(int y = 0; y < 1; y++) { for(int x = 0; x < 60; x++) { pushMatrix(); translate(x*7,y*7); s(); // funtions aufruf squaresclr++; popMatrix(); } } squaresclr = 0; translate(0,30); for(int y = 0; y < 1; y++) { for(int x = 0; x < 60; x++) { pushMatrix(); translate(x*7,y*7); m(); // funtions aufruf squaresclr++; popMatrix(); } } squaresclr = 0; translate(0,320); for(int y = 0; y < 1; y++) { for(int x = 0; x < 24; x++) { pushMatrix(); translate(x*7,y*7); h(); // funtions aufruf squaresclr++; popMatrix(); } } } //Funktion s void s() //seconds { if (squaresclr < second ()) { fill(255,0,0); } else { fill(0); } quad(5,5, 15,5, 10,15, 5,15); } //Funktion m void m() //minutes { if (squaresclr < minute ()) { fill(0,0,255); } else { fill(0); } quad(5,5, 15,5, 10,10, 5,10); } //Funktion h void h() //hour { if (squaresclr < hour ()) { fill(225,195,0); } else { fill(0); } quad(5,5, 15,5, 10,10, 5,10); }
![](http://blogs.iad.zhdk.ch/codingspace/files/2012/10/Bildschirmfoto-2012-10-02-um-01.17.04.png)