Hello folks.
I have finally sorted out what my first project will be. Now I'm stuck lol. A huge portion of my game will depend on the amount of time that has passed.
An example of what I am trying to do;
Say I want to simulate the discharging of a battery.
Start
BatteryCharge = 100 (static # or percentage, either would work)
**a mix of percentage drain on a static # would be ideal.
After one hour of Real World Time the Battery Charge would = 80 (again static # or percentage would work)
The math basics I get what I'm stuck on is 2 things.
How do I pull current time and build a counter around that ?
How can I make it so that if you close the game all together and come back an hour later and load it, an hour has still passed and the battery is still drained by 20% / 20 points ??
Any assistance with how to code this and or how to get time and count from it both during play and offline time, would be greatly appreciated. As i stated this is a big part of my game idea. The HUD/GUI 2d tile grid etc etc I can handle in lua.
Thank you again for your feedback / assistance
time based couters
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
time based couters
"We do not stop playing because we grow old. We grow old because we stop playing." -- Unknown
- nevon
- Commander of the Circuloids
- Posts: 938
- Joined: Thu Feb 14, 2008 8:25 pm
- Location: Stockholm, Sweden
- Contact:
Re: time based couters
Use os.time to get the current timestamp. Save that timestamp along with your charge and whatever else you need to save, in the love.quit callback. Then when the game is loaded again, the elapsed time is os.time()-oldTimestamp.
Re: time based couters
Awesomesauce thank you so much for the quick and informative response. I appreciate it.
for some reason I could not get time::gettime out of my head.. lol
for some reason I could not get time::gettime out of my head.. lol
"We do not stop playing because we grow old. We grow old because we stop playing." -- Unknown
- BlackBulletIV
- Inner party member
- Posts: 1261
- Joined: Wed Dec 29, 2010 8:19 pm
- Location: Queensland, Australia
- Contact:
Re: time based couters
By the sounds of it, a tweening library would help. EmmanuelOga's tweener library might do the trick.
- nevon
- Commander of the Circuloids
- Posts: 938
- Joined: Thu Feb 14, 2008 8:25 pm
- Location: Stockholm, Sweden
- Contact:
Re: time based couters
Whut? How do you figure that?BlackBulletIV wrote:By the sounds of it, a tweening library would help. EmmanuelOga's tweener library might do the trick.
- BlackBulletIV
- Inner party member
- Posts: 1261
- Joined: Wed Dec 29, 2010 8:19 pm
- Location: Queensland, Australia
- Contact:
Re: time based couters
Argh, I didn't read that.Wulfie wrote:How can I make it so that if you close the game all together and come back an hour later and load it, an hour has still passed and the battery is still drained by 20% / 20 points ??
From what I skimmed I originally thought that Wulfie wanted a timer that wasn't lasting, which a tween can pull off fine (although the practicality of an hour tween I don't know).
Who is online
Users browsing this forum: Bing [Bot] and 4 guests