I've replaced the use of drawsprite with a simple command that creates a polyvector instead, due to improved performance and greater flexibility that polyvector provides. Also since I'm using large graphics and there is clipping, I updated the command to be a little smarter, only drawing in the screen and what is visible.
screen_width and screen_height need to be defined by you though. Doesn't have scaling or rotation features yet, but I need to do them soon for my project.
FUNCTION DrawPolySprite: image, x, y, w, h, color
LOCAL adjx = x, adjy = y, adjw = w, adjh = h, adjsw = 0, adjsh = 0, adjpw = w, adjph = h
//Optimize
IF x < 0
adjx = 0
adjsw = -x
adjpw = w+x
ELSEIF x+w > screen_width
adjw = w+screen_width-x
adjpw = adjw
ENDIF
IF y < 0
adjy = 0
adjsh = -y
adjph = h+y
ELSEIF y+h > screen_height
adjh = h+screen_width-y
adjph = adjh
ENDIF
//Create
STARTPOLY image, 0
POLYVECTOR adjx, adjy, adjsw, adjsh, color
POLYVECTOR adjx, adjy+adjph, adjsw, adjh, color
POLYVECTOR adjx+adjpw, adjy+adjph, adjw, adjh, color
POLYVECTOR adjx+adjpw, adjy, adjw, adjsh, color
ENDPOLY
ENDFUNCTION
Um, I'm being lazy and should really spend 10 mins writing a routine to test this, but is polyvector faster than drawsprite? Surely not.
With tests, I also wonder the efficiency of this, especially on the iPhone. To find if the DRAWSPRITE function, that is partially drawn on the screen, faster than the spliced DrawPolySprite function calculations. :blink:
I haven't tested it much either, but it does provide some features over drawsprite like coloring vectors and scaling/tiling.
Also if you're using the same image, you can extract the start poly and endpoly, which I have done with another command called 'setpolysprite'
startpoly img, 2
newpolystrip
setpolysprite
endpoly
Something like that, good for handling lots of the same image. You can mess around with it further to support tilesheets, but I haven't done that myself. In theory though, you can have large chunks of your graphics on spritesheets and really take advantage of polysprite that way.
I use this mostly to handle the larger images that make of the map for my horizontal shooting game.