MasterLee wrote:Thats why i told the sprite position should be defined by upper left conner
Ah, I missed that part. In general I think he has the right idea placing the origin at the center, though.
x=((x-spritezise/2)%size)+spritesize/2
Yes, that does work nicely. Not sure if it's an improvement overall; getEdge is simpler like this, but at the expense of more convoluted (and brittle) position wrapping. I'd probably prefer leaving getEdge as it was and using x%size for position wrapping, but I suppose the "better" solution is a matter of personal preference.