Computer Science Canada starting timer later on in the program |
Author: | awesomeneptunian [ Tue Jan 23, 2018 2:29 pm ] |
Post subject: | starting timer later on in the program |
I'm trying to make a game, and naturally, I have an opening screen, but also, I need to make a timer for each separate level. My problem is that even though I initialize my timer variable at the point in the code where I would like it to start, it measures time from the beginning. Not sure how to solve this problem, I've experimented with Time.DelaySinceLast but I'm not entirely sure how that command works, nor do I think that this is what it's meant for. My game code is about 1200 lines, so let's just go with this basic format. View.Set ("graphics:max,max,nobuttonbar") var timer1 : int := 0 var x, y, button : int var font8 := Font.New ("courier:40:bold") loop Mouse.Where (x, y, button) exit when button = 1 end loop View.Update drawfilloval (maxx div 2, maxy div 2, 40, 40, black) View.Update delay (2500) Draw.Cls loop timer1 := Time.Elapsed %after the click is where I would like the timer to start Font.Draw (intstr (timer1 div 1000 mod 60), maxx div 2, maxy div 2, font8, black) View.Update Draw.Cls end loop Anyways, see my problem? For me, each level has an intro, and once it is over, THEN the timer should begin, but this does not work. I am using 4.1.1 on Turing. Please answer ASAP! This is super urgent. |
Author: | Insectoid [ Tue Jan 23, 2018 11:03 pm ] |
Post subject: | RE:starting timer later on in the program |
You can use a couple of timer variables and very basic math with Time.Elapsed to do exactly what you want. See if you can figure it out. |
Author: | TokenHerbz [ Wed Jan 24, 2018 3:12 am ] |
Post subject: | RE:starting timer later on in the program |
see your main post here : http://compsci.ca/v3/viewtopic.php?t=40571 and mods remove this one thanks |
Author: | Insectoid [ Wed Jan 24, 2018 12:51 pm ] |
Post subject: | RE:starting timer later on in the program |
I removed the other thread because somebody gave away the answers there. Isn't it more fun to help OP find the answers himself? |
Author: | TokenHerbz [ Thu Jan 25, 2018 1:04 am ] |
Post subject: | RE:starting timer later on in the program |
Good call!! i dont even remember posting this thread so it was probably me in my drunkin stoop!! LOL |
Author: | TokenHerbz [ Thu Jan 25, 2018 5:05 am ] |
Post subject: | RE:starting timer later on in the program |
turned out i made a fully functional module also that night, i can import easily and its multi-timer accessable and easy to use... cool, proud of my drunk self lmao... |