10-14-2003, 09:08 PM
Make a routine which draws the "n" vertices of a regular polygon. Those vertices must be stored in memory (a shared array or whatever). Use whatever memory representation you need.
The sollution which takes less memory to store the polygon wins. The coordinates should be floating point numbers (SINGLE).
For example, trivial sollution:
The above sollution uses n%*4*2 bytes (2 coordinates for each one of the n% vertices, each one taking 4 bytes for being a SINGLE value).
That can be done in a much better way which only would take 12 bytes per poly Can you guess?
If not, try at least to minimize used memory. You have to use SINGLEs.
The sollution which takes less memory to store the polygon wins. The coordinates should be floating point numbers (SINGLE).
Code:
DIM SHARED PolyData(????) AS SINGLE
SUB DrawPoly(n%)
For example, trivial sollution:
Code:
SUB DrawPoly(n%)
oldx!=PolyData(0)
oldy!=PolyData(1)
FOR i%=1 TO n%
if i%<n% THEN
x!=PolyData(i%*2)
y!=PolyData(i%*2+1)
ELSE
x!=PolyData(0)
y!=PolyData(1)
ENDIF
LINE (oldx!, oldy!) - (x!,y!)
oldx!=x!
oldy!=y!
NEXT
END SUB
The above sollution uses n%*4*2 bytes (2 coordinates for each one of the n% vertices, each one taking 4 bytes for being a SINGLE value).
That can be done in a much better way which only would take 12 bytes per poly Can you guess?
If not, try at least to minimize used memory. You have to use SINGLEs.
SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i