Computer Science Canada

Approach to Timer Animation

Author:  Beastinonyou [ Wed Sep 28, 2011 2:25 pm ]
Post subject:  Approach to Timer Animation

Alright, I am going through ideas for extra tidbits to add my assignment, and I'm thinking of adding a Clock-Like Timer at the top of the screen, With a hand that starts at 0 (or 12 O'Clock), moves Clockwise inside the circle for the duration of a minute (or any specific time), and stop back at the beginning, which executes a "Time Expired" sorta thing.


It's like in games, when you summon something, and there is a timer thing over the graphic of that summon, and when it's done, you can summon again. That's sorta the same thing.


How would I approach making the hand of the clock / timer move around the circle, in relation to the duration of time? Also, what if it were a Square and not a circle?


Thanks in Advance =)

Author:  Tony [ Wed Sep 28, 2011 4:19 pm ]
Post subject:  RE:Approach to Timer Animation

there's a timemodule that will let you have all kinds of time-related functions. Certainly enough to construct cooldown timers (the term for what you are describing).

The animations are pretty simple, in a way that if you are 10% into the cooldown, then you draw the animation that is 10% complete. E.g. 360 degrees * 10% == at 36 degree angle.

Author:  Beastinonyou [ Thu Sep 29, 2011 9:51 pm ]
Post subject:  Re: Approach to Timer Animation

After some thinking and fiddling around, I found out a timer would not work well when you're supposed to be getting input at the same time (Intended to be a countdown til it skips the question, considering it's a math flash card game for an assignment)

However, It is still useful I know how to work with Time.Elapsed, for my Final Project will surely need "Cooldown Timers".

Turing:

var maxSeconds : int := 60
var seconds : int := 0
loop
    if Time.Elapsed < (maxSeconds * 1000) then
        if Time.Elapsed div 1000 > seconds then
            cls
            seconds += 1
            put seconds ..
            drawfillarc (maxx div 2maxy div 220209090 - (seconds * round(360 / maxSeconds)), grey) 
            % div in place of / results in stop at 59s with a sliver left (at the 360 / maxSeconds)
        end if
    end if
end loop

Author:  Tony [ Thu Sep 29, 2011 10:14 pm ]
Post subject:  Re: Approach to Timer Animation

Beastinonyou @ Thu Sep 29, 2011 9:51 pm wrote:
After some thinking and fiddling around, I found out a timer would not work well when you're supposed to be getting input at the same time

If it's because of a technical reason, then you need to be using non-blocking IO, such as
code:

if hasch then
   getch c

and read input one character at a time.


: