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:
sync on
sync rate 60
REM << create array to hold values
dim time(3)
do
REM << record current time into a string
time$ = get time$()
text 5,5,"The get time$() command is returning the value of " + time$
REM <<<<<<<<<<<<<<<<<< string dessemblement >>>>>>>>>>>>>>>>>>>
REM << seperate string into three values(hour,mins,secs)leaving out colons
count = 5
for t = 1 to 3
REM << get both digits
time(t) = val(left$(time$,2))
REM << delete used digits and next colon
if t < 3 then time$ = right$(time$,count)
dec count,3
next t
REM <<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
REM << print new values values as strings to the screen
text 5,20,"That is an army time of " + str$(time(1)) + " hours, " + str$(time(2)) + " minutes, and " + str$(time(3)) + " seconds."
REM << create standard time
if time(1) => 13
time(1) = time(1) - 12
symbol$ = "pm"
else
symbol$ = "am"
endif
text 5,35,"That is a standard time of " + str$(time(1)) + ":" + str$(time(2)) + ":" + str$(time(3)) + symbol$
sync
cls
loop
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:
do
REM << we use one variable and timer command to edit seconds, minutes and hour values
if newtime = 0
checktime = timer()
newtime = 1
endif
REM << here, we subtract the values each loop, checking if it is => 17(60th of a second)
if timer() - checktime => 17
REM << enable the timer to be reset
newtime = 0
REM << update value in seconds
inc seconds
REM << update value in minutes if seconds has gone over 60
if seconds => 60
seconds = 0
inc minutes
endif
REM << update value in hours if minutes has gone over 60
if minutes => 60
minutes = 0
inc hours
endif
endif
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+