We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi guys, once again, I'm stuck with processing. I'm trying to write a countdown using day(), hour(), ecc. The problem is that I want the countdown to start counting starting from 09 days then goes until 00 days, and then it starts again. I'm trying to use day() because I want to use the code on a website (it should run in this sense, should it?)`` I would really appreciate your help guys, thanks.
PFont font;
String timesec = "01";
String timemin = "01";
String timeore = "01";
String timeday = "01";
int day;
int intervalday = 21;
int ore;
int intervalore = 24;
int m;
int intervalmin = 60;
int s;
int intervalsec = 60;
void setup()
{
size(300, 300);
font = createFont("Verdana", 30);
background(255);
fill(0);
}
void draw()
{
background(255);
//day TO-DO
day = TODO
timeday = nf(day, 2);
if(day == 0){
println(" ");
intervalday+=10 ;
}
text(timeday, width/5, height/5);
//ore
ore = intervalore -int(hour());
timeore = nf(ore, 2);
if(ore == 0){
println(" ");
intervalore+=10;}
text(timeore, width/3, height/3);
//minuti
m = intervalmin -int(minute());
timemin = nf(m, 2);
if(m == 0){
println(" ");
intervalmin+=10;}
text(timemin, width/4, height/4);
//secondi
s = intervalsec-int(second());
timesec = nf(s , 2);
if(s == 0){
println(" ");
intervalsec+=10;}
text(timesec, width/2, height/2);
}
Answers
As said, use ctrl-t in the processing IDE
and here in the forum use ctrl-o for code formatting
http://StackOverflow.com/questions/7829571/milliseconds-to-days
https://developer.Mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date