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

Username:   Password: 
 RegisterRegister   
 How to make a Timer
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Waked




PostPosted: Sat Jun 02, 2012 8:36 pm   Post subject: How to make a Timer

im trying to make a timer for my game but im having some trouble with it and hope someone could help.
Thanks.
here is what i have so far:

setscreen ("offscreenonly")

var timeRunning : int := 0
var font := Font.New ("comicsansms:19:bold")

loop
timeRunning := Time.Elapsed
cls
Font.Draw ("Time Running: " + intstr (round (timeRunning / 1000 / 60)) + ":" + intstr (round (timeRunning / 1000)), maxx div 2 - 105, maxy - 35, font, 7)
View.Update
end loop
Sponsor
Sponsor
Sponsor
sponsor
crossley7




PostPosted: Sat Jun 02, 2012 8:52 pm   Post subject: Re: How to make a Timer

think about what your timer is doing then think which of the 3 rounding functions you want to use.
Round, floor, ceil.

Also, what is the highest value you want for the seconds part? What mathematical function can you apply to what you have to ensure that is always the case.

I recommend you try to figure it out on your own, but if you highlight below, the answer will appear

Use floor and for the seconds, mod the value you have by 60
Waked




PostPosted: Sat Jun 02, 2012 8:55 pm   Post subject: RE:How to make a Timer

Alright! thank you verry much!
Waked




PostPosted: Sat Jun 02, 2012 9:12 pm   Post subject: RE:How to make a Timer

and also could you please helping me with displaying minutes and seconds as 2 digit numbers always?
crossley7




PostPosted: Sat Jun 02, 2012 10:01 pm   Post subject: RE:How to make a Timer

just use separate if statements for if your minutes is less than 10, minutes is less than10 and both are less than 10. Then just output an extra 0 where you need it to be. With font.draw I think that is about as good a solution as you get
Waked




PostPosted: Sun Jun 03, 2012 9:23 am   Post subject: RE:How to make a Timer

ok. Thanks Smile
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  [ 6 Posts ]
Jump to:   


Style:  
Search: