Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Rotating some points , seems slow
#2
slenkar Wrote:I was going to make a vector graphics game like asteroids but different
I rotated some points around an origin but even that seems too slow

I was going to draw lines between the points
There is little you can do in your code, I guess. Some tips:

  1. Not a huge optimization, but more elegant: initialize the trishipx array directly
  2. 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.
  3. The above might be even faster if you use PEEK instead of array access.
  4. 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
To be rewritten as
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
And remember that variables declared (DIMed) within a function have slower access. This is because they are relative to the stack pointer (IX). Global variables are much faster. At the moment the compiler does not support static variables. :oops:

Maybe Britlion can give you more suggestions, as he is an optimization expert Tongue
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)