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 / Really need help with timer functions

Author
Message
Ashley
20
Years of Service
User Offline
Joined: 17th Apr 2004
Location:
Posted: 17th Apr 2004 22:33
If you remember the atari arcade game Dragons Lair then you will know exactly what im trying to do, if not ill try to explain best i can.

i have loads of avi files im using as part of a game, by viewing the small action scenes the user will have to make quick keypresses either up down left right or space (action), make the movement to slowly or to quickly will result in a death scence (avi) file being shown, make the movement on time and you get next level avi.

trouble is im not sure how to work out the timer, i dont want the user to be able to just keep pressing required keypress until time is right, and only want a margin of one second to make keypress

so ay help with small piece of timer code would be really apreciated. thanks in advance.

Ash
DK_
20
Years of Service
User Offline
Joined: 4th Jan 2004
Location:
Posted: 17th Apr 2004 22:51 Edited at: 17th Apr 2004 22:52
you could use the "timer()" command

when you begin the program timer() continually increases from zero
so you could get the time from when the event starts and subtract it from when the user presses the button to see if they made it within the time margin.

Syntax:
Return Integer=TIMER()

the time is returned in milliseconds.

I hope this answers your question.

Mentor
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: United Kingdom
Posted: 18th Apr 2004 14:17 Edited at: 18th Apr 2004 14:22
just play the avi, and say after ten seconds you have a one second window for the keypress then do this

fight=1:killed=2
load animation "fight.avi",1
load animation "killed.avi",2
play animation fight
t=timer()
t=timer+10000
t2=t+1000
repeat
if (timer()>t) and (timer()<t2) and inkey$()="f"
FightTheBadguy()<<<<<<<<<<<<<<<function that playes the fight sequence!!!
endif
until (animation playing(1)=0)
play animation killed

that would play the animation and allow the player to press a key that will only have any effect if the time is between 10 to 11 seconds into the animation, if like you say you have a stack of these animations that need to be proccesed than I would suggets you make an "engine" to run them and detect the appropriate keypresses, and have corresponding "inf" files for each animation that you can load, they could hold (for example)

time allowed until keypress
time allowed for keypress
name of file to pay if pressed in time
name of file to pay if you get killed

and any other information you could think of, hope thats some help, cheers.

Mentor.

PC1: P4 hyperthreading 3ghz, 1gig mem, 2x160gig hd`s, ATI radeon 9800 pro gfx, 6 way surround sound, PC2: AMD 1.2ghz, 512mb ram, FX5200 ultra gfx, stereo 16 bit soundblaster, ups.

Login to post a reply

Server time is: 2024-09-22 06:40:08
Your offset time is: 2024-09-22 06:40:08