Creating a countdown clock, quick question...

BlitzMax Forums/BlitzMax Programming/Creating a countdown clock, quick question...

Arowx(Posted 2009) [#1]
Hi I'm working on a countdown clock made up from segments of a circle, so as it counts down segments are removed.

e.g. outer 'Dial' hours, next 'Dial' minutes, inner 'Dial' seconds.

Now this works quite well but can end up drawing a lot of segments each frame, as it's only used in a coundown timer app this is not a problem, however...

Segments drawn a line at a time...
every 0.3 degrees = 1200 draws x 3 dials = 3600!

Hmm but even the second dial will only need re-drawing once ever 60 frames...

Ok the problem is in a game where would you put and how would you manage the pre-render code, given that:

1. Were using Rotation to create the segments
2. and Images to draw the segments

Any thoughts ideas?


xlsior(Posted 2009) [#2]
Ony idea for speedup: Don't draw just a segment at a time, but instead use some sprites that encompass multiple segments, and figure out which ones to draw.

e.g. have a triangle image that is the size of 2 segments, 4 segments, 8 segments, 16 segments, 32 segments, 64 segments, 128 segments, 256 segments, 512 segments, etc. Then when blanking out your dial rotate & draw a combination of these segments to accomplish what you want.

If you have 386 segments, you can then 'just' draw the 256 + 128 +2 segments, which is 3 draw commands instead of 386. Just do the math to figure out how to rotate the individual segment sprites properly so they appear as one.