
-----------------------------------
awesomeneptunian
Tue Jan 23, 2018 2:29 pm

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.

-----------------------------------
Insectoid
Tue Jan 23, 2018 11:03 pm

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.

-----------------------------------
TokenHerbz
Wed Jan 24, 2018 3:12 am

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

-----------------------------------
Insectoid
Wed Jan 24, 2018 12:51 pm

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?

-----------------------------------
TokenHerbz
Thu Jan 25, 2018 1:04 am

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

-----------------------------------
TokenHerbz
Thu Jan 25, 2018 5:05 am

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...
