Sprite handles

Previous topic - Next topic

fuzzy70

Is there a command to change the X & Y handles of a sprite. From what I have made out DRAWSPRITE uses the top left corner (0,0) of the sprite for it's drawing whereas ROTOSPRITE uses the centre of the sprite. Basically I want to rotate around a certain point & not the middle of the image.

If it means me making a routine using polyvectors then that's not a problem but I thought I would check before re-inventing the wheel so to speak  :D

Lee
"Why don't you just make ten louder and make ten be the top number and make that a little louder?"
- "These go to eleven."

This Is Spinal Tap (1984)

MrTAToad

No, it would be nice if there was, but you need to calculate it all yourself.  I borrowed this from the oSprite routine :

Code (glbasic) Select
FUNCTION DrawSpr_Scale%:spriteID%,spriteIndex%,x,y,angle,scale,useScale%=TRUE
LOCAL cosp,sinp,sx,sy,px,py,rx,ry

IF useScale%=TRUE
scale=scale*self.maxScale
ENDIF

cosp=COS(angle)
    sinp=SIN(angle)

    sx = self.spriteLoadData[spriteID%].xSize%/2.0
    sy = self.spriteLoadData[spriteID%].ySize%/2.0

// Always revolve around the centre
    px = self.spriteLoadData[spriteID%].handleXOffset%-sx
    py = self.spriteLoadData[spriteID%].handleYOffset%-sy

    // reverse rotate pivot point around center
    // of sprite
    rx = (px*cosp + py*sinp) * scale
    ry = (py*cosp - px*sinp) * scale

    // adjust center
    INC rx,sx
    INC ry,sy

IF spriteIndex%<0
    ROTOZOOMSPRITE self.spriteLoadData[spriteID%].idNumber%,x-rx,y-ry,angle,scale
    ELSE
    ROTOZOOMANIM self.spriteLoadData[spriteID%].idNumber%,spriteIndex%,x-rx,y-ry,angle,scale
    ENDIF
ENDFUNCTION

fuzzy70

Thanks for that, will have a play. I can figure out the references to the TYPE that was used  =D

Lee
"Why don't you just make ten louder and make ten be the top number and make that a little louder?"
- "These go to eleven."

This Is Spinal Tap (1984)

spacefractal

Actuelly I have really nightmare just because that center hotspot in Greedy Mouse and took long time to place those thing top left and fix eventuelly scaling issues (even rotating was not used), that allways do some strange thing. So its absolute not easy at all, unlike blitzmax.

So in the request thing, a HOTSPOT x,y would been really cool to have and some thing could been much easier. Howover its could of course been in a type really :-D.

Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation - The beagle Jam - Cave Heroes 2023 - https://spacefractal.itch.io/