2
I have a question in Java. Basically, I wanted to get a fillrect to draw 0.5 in 0.5 seconds, more or less this way:
if(passedTime >= 0 && passedTime < 500) {
g.fillRect(0, 45, 64, 64);
}
if(passedTime == 500 && passedTime < 1000) {
g.fillRect(0, 35, 64, 64);
}
if(passedTime == 1000 && passedTime < 1500) {
g.fillRect(0, 25, 64, 64);
}
if(passedTime == 1500 && passedTime < 2000) {
g.fillRect(0, 15, 64, 64);
}
if(passedTime >= 2000) {
g.fillRect(0, 0, 64, 64);
}
and passedTime would be:
long initTime = System.currentTimeMillis();
long endTime = System.currentTimeMillis();
long passedTime = endTime - initTime;
I wanted precisely that up to 500 milliseconds (0.5 seconds) he would make this fillRect , after 500 until 1000 do the other, and always so until 2 seconds. I am new to java and would like to know what I have to do and to what extent is wrong what I did. Thank you
Thread.sleep(500)
– nullptr