Computer Science Canada Need Help wth Time.Elapsed |
Author: | Graeme [ Fri Mar 10, 2006 8:43 am ] |
Post subject: | Need Help wth Time.Elapsed |
Hello, I am currently working on a program and i need it so that after every 2 minutes "health" is decreased by 15% I know I will need to use Time.Elapsed, But I am unsure how I would get the health to decrease every 2 minutes thanks for your help |
Author: | Albrecd [ Fri Mar 10, 2006 9:14 am ] |
Post subject: | |
Time.Elapsed gives the number of milliseconds that have passed so far in your program. To use it, you have to have a variable (:int) which must then be given the value of Time.Elapsed. Then when your variable is at the number of milliseconds you want, decrease health. |
Author: | do_pete [ Fri Mar 10, 2006 12:42 pm ] | ||
Post subject: | |||
Something like this will work:
|
Author: | Graeme [ Fri Mar 10, 2006 5:03 pm ] |
Post subject: | |
Thanks alot for the help Yeah I previously had a varibale declared I have var health : string := "100" var startTime := Time.Elapsed loop if Time.Elapsed - startTime >= 120000 then put health end if end loop I have that, but now I want to get it so that every 2 minutes, it goes down 25% , so 100,75,50,25,0 etc etc ...i just dont know how i would get it to decrease each 2 mins, i have an idea, but i can't seem to get it to work. thanks for the help |
Author: | Cervantes [ Fri Mar 10, 2006 6:07 pm ] | ||
Post subject: | |||
Keep a variable, health_decrease_time that represents the last time the health was decreased.
|
Author: | [Gandalf] [ Fri Mar 10, 2006 7:36 pm ] | ||
Post subject: | |||
Graeme wrote:
Care to tell me why the variable health is a string? It should be an int. |