hajar424 Posted July 11, 2015 Posted July 11, 2015 How do you add a counter or something that show how many seconds,minutes and hours you have played?
Twin Posted July 12, 2015 Posted July 12, 2015 Go into the tutorial section, and look at Pugs guide on paint. 1
blabla123 Posted July 12, 2015 Posted July 12, 2015 Declare these as globals (secs,mins,hrs can be declared inside onPaint() if you'd like) long startTime; long timeRunning; long seconds, minutes, hours; and set onStart(){ startTime = System.currentTimeMillis(); } and onPaint(Graphics2D g){ timeRunning = System.currentTimeMillis() - startTime; hours = timeRunning / 3600000; timeRunning -= hours * 3600000; minutes = timeRunning / 60000; timeRunning -= minutes * 60000; seconds = timeRunning / 1000; // and now just print it, for example g.drawString("Time: " + hours + "h " + minutes + "m " + seconds + "s", x, y); }