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.

Code Snippets / Game Timer

Author
Message
cyrano
21
Years of Service
User Offline
Joined: 7th Dec 2002
Location:
Posted: 20th Dec 2002 20:52
Here's a timer I coded that tracks action keys being pressed. It tracks in seconds no matter how quickly the player presses and releases the action keys. Pretty accurate for anyone looking for a timer for their game.

Here's the code:

remstart
Game Timer

The timer basically keeps track of two different times
One tracks the time pressing an action key (upkey in this case)
The other tracks the time while no keys are being pressed
In order to keep track of action time, both action and nonaction times must be tracked
remend

randomize (timer())
sync on

rem create random number between 9 and 15
random_number = rnd(6)
random_number = random_number + 8

rem - set flags for nonaction and first time to press upkey
stop_flag=1
firstmove=0:rem Set the first time upkey is pressed

do
cls

print "Random Number ";random_number
print "Total Seconds the player is pressing up key: ";(seconds/1000)
print "Seconds player is not pressing up key: ";(time_minus/1000)

if upkey()1 and first_move=1 then gosub keep_minus_time:
if upkey()=1 then gosub time_keeper:

if (seconds/1000) > random_number then print "Player attack now ":end

sync
loop

time_keeper:
inc time_flag:if time_flag
cyrano
21
Years of Service
User Offline
Joined: 7th Dec 2002
Location:
Posted: 20th Dec 2002 20:54
Oops, cut out part of the code, here it is in full:


Login to post a reply

Server time is: 2024-03-29 02:15:52
Your offset time is: 2024-03-29 02:15:52