Game Timer Problem
Author |
Message |
Zhanger
|
Posted: Tue Jan 14, 2014 5:28 pm Post subject: Game Timer Problem |
|
|
What is it you are trying to achieve?
Making a timer that displays the amount of time spent within a game.
What is the problem you are having?
The timer does not display properly after being cleared with cls.
When cls is removed the timer works perfectly but the object gets a trail.
Describe what you have tried to solve this problem
I looked on the forums for answers but couldn't find anything.
I tried using a process and forking it but that didn't work properly.
Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
Turing: |
var last, now, count : int := 1
var x, y : int := 100
var chars : array char of boolean
last := Time.Elapsed
View.Set ("offscreenonly")
put count
loop
Input.KeyDown (chars )
if chars (KEY_UP_ARROW) then
y := y + 5
end if
if chars (KEY_RIGHT_ARROW) then
x := x + 5
end if
if chars (KEY_LEFT_ARROW) then
x := x - 5
end if
if chars (KEY_DOWN_ARROW) then
y := y - 5
end if
now := Time.Elapsed
if (now - last >= 1000) then
count + = 1
locate (1, 1)
put count
last := now
end if
drawoval (x, y, 4, 4, red)
View.UpdateArea (0, 0, maxx, maxy)
delay (10)
cls %Comment this to see object trail
end loop
|
Please specify what version of Turing you are using
4.11 |
|
|
|
|
|
Sponsor Sponsor
|
|
|
Raknarg
|
Posted: Tue Jan 14, 2014 6:35 pm Post subject: RE:Game Timer Problem |
|
|
It's probably because you only ever put the time once per 50 frames. One of those frames you put count, but not the other 49. It's a very simple fix. |
|
|
|
|
|
Zhanger
|
Posted: Tue Jan 14, 2014 7:32 pm Post subject: Re: Game Timer Problem |
|
|
Thanks a ton! I've got it working now. |
|
|
|
|
|
|
|