Computer Science Canada

TIMERS FOR GAMES!!!

Author:  nate [ Fri Mar 28, 2003 5:36 pm ]
Post subject:  TIMERS FOR GAMES!!!

I am making this Sniper game and I want to have a timer so that if you do not kill the person in a certain amount of time you will lose or something but I was wondering if anyone could give my the code for a TIMER Exclamation

Also If anyone can give me good Ideas that would impress my teacher that would be greatly appreciated

Thanks
-Nate

MOD EDIT: Moved to turing help

Author:  Asok [ Fri Mar 28, 2003 6:18 pm ]
Post subject: 

code:
Time.Elapsed


you can check usage in the Turing help file.

Author:  Dan [ Fri Mar 28, 2003 6:27 pm ]
Post subject: 

there are a few difrent ways you could do this.

the simpisted being, puting a couter in a loop.

but if you whont to use real time then i whod use the time comands

ex.

code:

var oldtime:int := Time.Sec

loop
locatexy(maxx div 2, maxy div 2)
put Time.Sec - oldtime
end loop

Author:  haujobb [ Mon Mar 31, 2003 9:00 pm ]
Post subject: 

you would have to put it in a process:

var time : int := 30

process countDown ()
delay(1000)
time := time - 1
end countDown

then:

fork countDown ()

you might have to include time as an argument, im to lazy to remember....

Author:  azndragon [ Mon Mar 31, 2003 11:16 pm ]
Post subject: 

If you wanted to include the timer as an arguement, use this:

code:
process timer (seconds : int)
    delay (seconds * 1000)
    cls
    put "Bye"
end timer

fork timer(2)
put "Hi"


That just displays hi, and after 2 seconds, displays bye.


: