Jun 12, 2019 06:27 AM
(This post was last modified: Jun 12, 2019 08:42 AM by deadsh0t.)
So im doing and endproject on my first year of aplication developer, we need to make snake and i already finished the snake part however we need to use a stopwatch to keep track of the playtime.
I did it like this:
where end is the current system time in millisec and start is set once at the beginning of the game it also takes the current system time in millisec.
However the problem is i need to be able to pause the game and the stopwatch also needs to be paused however since its using the current system time when the timeline resumes its like the stopwatch never stopped.
I find it a bit hard to think about a logical solution since ive been programming for a few hours straight.
please enlighten me 😉
UPDATE: FIGURED IT OUT
I did it like this:
Code
long s = ((end - start) /1000) % 60;
long m = (((end - start) /1000) / 60) % 60;
long milli = (end - start) % 1000;
System.out.println( String.format(" %02d:%02d.%03d", m,s,milli));
return String.format(" %02d:%02d.%03d", m,s,milli);where end is the current system time in millisec and start is set once at the beginning of the game it also takes the current system time in millisec.
However the problem is i need to be able to pause the game and the stopwatch also needs to be paused however since its using the current system time when the timeline resumes its like the stopwatch never stopped.
I find it a bit hard to think about a logical solution since ive been programming for a few hours straight.
please enlighten me 😉
UPDATE: FIGURED IT OUT
=============================================
Nothing yet
=============================================
Nothing yet
=============================================

