Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Geometry Challenge
#1
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).

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 Wink 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
Reply


Messages In This Thread
Geometry Challenge - by na_th_an - 10-14-2003, 09:08 PM
Geometry Challenge - by Mango - 10-15-2003, 12:27 AM
Re: Geometry Challenge - by Mango - 10-15-2003, 09:04 AM
Geometry Challenge - by relsoft - 10-15-2003, 11:36 AM
Geometry Challenge - by na_th_an - 10-16-2003, 09:14 PM
Geometry Challenge - by Mango - 10-17-2003, 01:17 AM
Geometry Challenge - by SCM - 10-17-2003, 10:52 AM
Geometry Challenge - by relsoft - 10-17-2003, 12:21 PM
Geometry Challenge - by na_th_an - 10-18-2003, 01:01 AM
Geometry Challenge - by SCM - 10-18-2003, 10:28 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)