Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Time.Elapsed
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Mr. T




PostPosted: Sun May 29, 2005 12:27 pm   Post subject: Time.Elapsed

is there a way to hault the Time.Elapsed from counting becuz..my scoring system bonus works on the amount of time u spend within a level. however, when the level is complete, a scoring chart appears...if u spend a long time in the scoring chart, the Time.Elapsed will still be counting milliseconds, and then u end up geting a negative bonus. please help.
Sponsor
Sponsor
Sponsor
sponsor
MysticVegeta




PostPosted: Sun May 29, 2005 12:45 pm   Post subject: (No subject)

code:
var tim : int
put "Press any key to win"
loop
    tim := Time.Elapsed
    exit when hasch
end loop
put "Your time was: ", tim div 1000, " seconds."
if tim < 10000 then
    put "Time bonus is: ", 10000 - tim
end if


This?
Mr. T




PostPosted: Sun May 29, 2005 12:52 pm   Post subject: Alex's Opinion

I'm not sure if that would work...let me give u some code.
code:

put "Your score is: ", score     %score with out additional time bonus
    var timeBonus : int := bonus - Time.Elapsed div 1000     %1 min timer (Time.Elapsed = 1000 milliseconds = 1 min)
    put "Your time bonus is: ", timeBonus     %time bonus
    score := score + timeBonus     %updated score = score as of to that point + time bonus
    put "Your overall score is: ", score     %score as of to that point + time bonus
    score:= 60 + (Time.Elapsed div 1000) %score reset
    put "[press enter to continue to next round]"     %gives the user time to read the score

the problem is that this reset line
code:

score:= 60 + (Time.Elapsed div 1000) %score reset

takes into affect before the game enters the next level...so the time is continually counting.
Cervantes




PostPosted: Sun May 29, 2005 2:50 pm   Post subject: (No subject)

Everytime you enter a new level, store the Time.Elapsed at that time into a variable. When you finish the level, use (Time.Elapsed - the_time_variable_from_the_start_of_the_level) to determine the score.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 4 Posts ]
Jump to:   


Style:  
Search: