How to make a Timer
Author |
Message |
Waked
|
Posted: 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
|
|
|
crossley7
|
Posted: 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
|
Posted: Sat Jun 02, 2012 8:55 pm Post subject: RE:How to make a Timer |
|
|
Alright! thank you verry much! |
|
|
|
|
|
Waked
|
Posted: 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
|
Posted: 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
|
Posted: Sun Jun 03, 2012 9:23 am Post subject: RE:How to make a Timer |
|
|
ok. Thanks |
|
|
|
|
|
|
|