04-08-2013, 08:04 AM
slenkar Wrote:I was going to make a vector graphics game like asteroids but differentThere is little you can do in your code, I guess. Some tips:
I rotated some points around an origin but even that seems too slow
I was going to draw lines between the points
- Not a huge optimization, but more elegant: initialize the trishipx array directly
- Most of the demos I know cache all pre-calculated values in a table. So do something like DIM fSIN(360) As Fixed might be a good idea.
- The above might be even faster if you use PEEK instead of array access.
- The lines in the fsin / fcos degree calculates twice these values.
For the last point, consider:
Code:
transformedX= fCos(degrees) * (trishipx(x)-pointx) - fSin(degrees) * (trishipy(x)-pointy) + pointx
transformedY = fSin(degrees) * (trishipx(x)-pointx) + fCos(degrees) * (trishipy(x)-pointy) + pointy
Code:
Dim fc, fs, tx, ty As Fixed
fc = fCos(degrees)
fs = fSin(degrees)
tx = trishipx(x) - pointx
ty = trishipy(x) - pointy
transformedX= fc * tx - fs * ty + pointx
transformedY = fs * tx + fc * ty + pointy
Maybe Britlion can give you more suggestions, as he is an optimization expert
