Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Countdown Timer based on System Clock

Author
Message
ShinyBug
9
Years of Service
User Offline
Joined: 9th Jan 2015
Location: United States
Posted: 9th Jan 2015 23:13
Hey everyone. My mail goal is to be able to create a timer to countdown hours/minutes/seconds based on the system clock AND to have the app save the values of the initial time and the timer to check if the timer finished its countdown while the app was closed.

Basically, I want to start a timer in-game, save all the values, close the game, reopen the game, load values and check if the timer has finished.

I've been trying to solve this problem for days now and I cant even figure out how to even start coding it. I feel like its possible, but I just cant wrap my head around the coding logic just yet.

Any advice?
JimHawkins
14
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 10th Jan 2015 10:25
You would need to make a shared service. That's not possible with AGK.

Onwards and sometimes upwards
Ched80
13
Years of Service
User Offline
Joined: 18th Sep 2010
Location: Peterborough, UK
Posted: 10th Jan 2015 12:48
You could use "GetCurrentDate()" and "GetCurrentTime()", store these to a local file when the timer starts and then calculate the difference between the saved values and the new values to see if the timer has finished.

ShinyBug
9
Years of Service
User Offline
Joined: 9th Jan 2015
Location: United States
Posted: 25th Jan 2015 23:27
Ok Thanks guys. I've been pecking at it but theres a strange output where the "getCurrentTime()" stops returning values after about 8 seconds. Im sure its an optimization problem. I think I'll just step away from it for a while and clear my head on it. I'll post the code in case anyone is curious. I set it up to load the last saved time and to display the current time and save it to file on mouse input.


Tone Dialer
Valued Member
18
Years of Service
User Offline
Joined: 17th Oct 2005
Location: England, well a town in it !
Posted: 26th Jan 2015 08:39 Edited at: 26th Jan 2015 08:40
@ShinyBug

I wanted to do something similar, but I would recommend using UNIX time/date as GetUnixFromDate() gives access to year, month, days, hours, minutes, seconds. Calculating the difference in time between the two is easier. Also I would not use GoSub/Return.

I wrote an example in the AppGameKit help files that you may find useful.

http://www.appgamekit.com/documentation/Reference/File/GetFileExists.htm



Login to post a reply

Server time is: 2024-04-17 00:43:24
Your offset time is: 2024-04-17 00:43:24