time based couters
Posted: Thu Apr 21, 2011 9:24 am
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
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