Willkommen auf unserem Seminar-Blog

Immer auf dem aktuellen Stand bleiben

Dieser Seminar-Blog befindet sich noch im Aufbau und wird in den kommenden Tagen entsprechend verfeinert.

Member Login

Lost your password?

Registration is closed

Sorry, you are not allowed to register by yourself on this site!

You must either be invited by one of our team member or request an invitation by email at viad.info {at} zhdk {dot} ch.

Tick Tock Clock

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);
}

Yet I encountered a flaw during the class discussion: after every minute the health points would drop to "0", which means the character in the game would die inevitably minute after minute. A clash resulted: The Health Points should rise or sink randomly by "1" as the seconds passes by, yet it wouldn't reach "0" vs. Would it be out of place if the second bar did not tell the exact time like the other bars in the game? In the end, I left it the way it was because out of personal experiences in games, it is not like one is invincible while playing Role-Playing-Games so taking out the risk of dying is quite like taking the fun and excitement out of it. ******************************************************** SMALL EXCURSION: "Race from One End to the Other" New: PVector What our code would do at the start: you would have to click, hold and drag to create a line. Once you release the mouse button, the line is complete and a white circle would slide across from one end to the other. Our goal: draw a line with the mouse by clicking once for the starting point and a second time for the finishing point. Upon clicking twice with the mouse, the animation with the circle would start. Like the class already mentions, you use vectors to work here. Vectorgeometry is really useful here due to the fact that once you know what vectors can do in maths, it opens up a whole range of possibilities of how to change things in processing.