Shop OBEX P1 Docs P2 Docs Learn Events
Polygon demo syntax question — Parallax Forums

Polygon demo syntax question

MinimumWageMinimumWage Posts: 72
edited 2007-08-08 22:47 in Propeller 1
Hello,

I'm hoping someone can answer what is probably a simple question. I'm working through the Hydra book and am dissecting the Polygon demo on pages 368-376. I don't quite understand the syntax given for the asteroid data structure. Specifically, if you look at the first two vertices:

word    $4000+$2000*45/360      ' vertex 0                        
word    8*2
                        
word    $8000+$2000*63/360      ' vertex 1                        
word    4*2

The plot / line and·polar angle notation I understand, but I·can't figure out why·the X * 2 notation for the length is used here. At first I thought it was some kind of pseudo-real number workaround, but that doesn't make sense for the lengths of the vertices which were calculated at 5.65 and 4.47 from the plot on page 369.

The excerpt is actually from the example code on CD, the code in the book lists everything as an X * 8 length.

Any clarification would be greatly appreciated! wink.gif

Mike

Comments

  • AndreLAndreL Posts: 1,004
    edited 2007-08-08 02:35
    Its just a scaling factor that's all, no magic, just me playing with the image and thinking "that's too small, that's too big" - -and using a number there everytime. That's all.

    Andre'
  • MinimumWageMinimumWage Posts: 72
    edited 2007-08-08 05:07
    Andre,

    Thanks, that makes sense. Did you also just experiment with different values to set the length? I was expecting to see something closer to the calculated values for the polar vectors from the graph drawing...

    Mike
  • AndreLAndreL Posts: 1,004
    edited 2007-08-08 21:33
    Well, there is the size of the screen, the speed of the line draw, etc. So I draw everything on graph paper using numbers large enough to represent some precision, like -10 to +10, using -1 to +1 is dumb since you can't represent decimals, thus using a semi large number like -10 to +10, you can draw something. Then when done, you have your vertex list and then the trick is to scale the data with a scale factor, so you can alter the data set and not have to re-enter it every time. If I was doing a real game, I would use something like -128 to +127 or some other power of 2 along with a scaling factor.

    Andre'
  • MinimumWageMinimumWage Posts: 72
    edited 2007-08-08 22:47
    Ok, that all makes sense to me now.

    I played around a bit last night with the vector demo just drawing triangles and other simple shapes and found that the length vectors didn't have to be exact. I could almost always round up or down to an integer value (from my plotted values)·and still not see any under- or overshoot onscreen at the vertices. It might show up worse on VGA, but for NTSC it looked fine.

    Thanks again for all the help - working through the book has been a blast so far!

    Mike
Sign In or Register to comment.