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.

Newcomers DBPro Corner / Something to think about - Game time independant of real time... Any suggestions?

Author
Message
PaulC
21
Years of Service
User Offline
Joined: 23rd Feb 2003
Location:
Posted: 5th Aug 2005 13:39
This has eluded me so far. I have a display of time in a developing game of mine, showing hours and minutes: the minutes in gametime take a second, and the gametime hours take a minute... At least they should. DBC (sorry) doesn't allow me to use the get time$() command as a variable. Ideally, I just want to stop it showing the hours, and just leave me with the minutes and seconds ticking past.

Suggestions would be most welcome, and thanks in advance.
NanoBrain
19
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Portland, OR
Posted: 5th Aug 2005 20:55 Edited at: 5th Aug 2005 20:58
PaulC,

Below is a snippet I have created some time back. It uses string manipulation to pull apart the string returned by the get time$() commmand, and converts it to usable number values. These values are placed into the time array. Slot 1 = hour, slot 2 = minute, slot 3 = second. As an added extra, this program prints your current time on the screen, in standard clock format.

Code:


The code above will only bring to you the speed of real time, not the speed you wish for game time. To get the game time you want, use the timer command. First, fill a variable once, with the current value from the timer() command. Note:This command, the timer command, counts up to 1000 in one second. Each loop, subtract your variable's value from the then current timer() command value. If that value is equal to or greater than one thousand, then a second has passed. You can manipulate this to create your game time, by setting the value to check for, lower, or higher. A value of 500 would be a half a second.

Let us create a system. Minutes take a second, hours take a minute(Might be too quick if you ask me, but I am not sure what your game is). With the needed time elapse here, seconds would only take a 60th of a second, or a 60th of 1000. Therefore, at 17(rounded up), a second hass passed.

Game-time clock system:


The code above will set the time moving at the speed you spoke about above. However, I have left the formatting for the displaying of time up to you. Good luck.


+NanoBrain+
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 5th Aug 2005 21:41
Newsletter 31 has a fantastic (ahem!) tutorial on creating timers and tickers. A ticker can represent any time frame. So you can, for example sate that 10 real seconds = 1 game minute, for example.

PaulC
21
Years of Service
User Offline
Joined: 23rd Feb 2003
Location:
Posted: 5th Aug 2005 22:47
Wow, thank you both of you. A credit to the community

Login to post a reply

Server time is: 2024-09-24 01:30:56
Your offset time is: 2024-09-24 01:30:56