I need a GETANIMSIZE command?

Previous topic - Next topic

spicypixel

I have a function to scale sprites according to a pre-calculated ZOOM factor, and this works quite well for simple sprite blitting. However I have come across the need for an instruction that just doesn't seem to be there. Here is my code for both DRAWSPRITE and DRAWANIM equivalents.

DRAWSPRITE
Code (glbasic) Select

//
// Zoom Scaled DRAWSPRITE Command
//
FUNCTION ZDRAWSPRITE: image%, x, y
LOCAL sizeX, sizeY
GETSPRITESIZE image%, sizeX, sizeY
STRETCHSPRITE image%, (x * ZOOM), (y * ZOOM), (sizeX * ZOOM), (sizeY * ZOOM)
ENDFUNCTION


DRAWANIM
Code (glbasic) Select

//
// Zoom Scaled DRAWANIM Command
//
FUNCTION ZDRAWANIM: image%, anim, x, y
LOCAL sizeX, sizeY
GETSPRITESIZE image%, sizeX, sizeY
STRETCHANIM image%, anim, (x * ZOOM), (y * ZOOM), (sizeX * ZOOM), (sizeY * ZOOM)
ENDFUNCTION


As you can see I'm using the GETSPRITESIZE for both functions and as expected the size given in the ZDRAWANIM is for the full sprite and not the individual animation sizes. I know the size for the individual animation I want to draw but it seems sensible to have a command to allow functions like this.

Do we need a GETANIMSIZE command or do you have a code alternative?
http://www.spicypixel.net | http://www.facebook.com/SpicyPixel.NET

Comps Owned - ZX.81, ZX.48K, ZX.128K+2, Vic20, C64, Atari-ST, A500.600.1200, PC, Apple Mini-Mac.

MrTAToad

#1
As animated sprites are always of a fixed cell width and height, you know the size when loading (would have needed it when loading).

If however, your animations are of arbitrary size then the easiest way would be to load the sizes into a sorted list (so they can be quickly searched for their size).

spicypixel

I also know the size of the sprite I'm loading too but we have a GETSPRITESIZE command. Just seems that it was an oversight thinking it not necessary but in certaun examples it is. I had thought about the storing of a list but opted for a FUNCTION where I passed the size to it already (as you mention I know it) so it was a nice compromise.

Code (glbasic) Select

FUNCTION ZDRAWANIM: image%, anim, x, y, width, height
STRETCHANIM image%, anim, (x * ZOOM), (y * ZOOM), (width * ZOOM), (height * ZOOM)
ENDFUNCTION
http://www.spicypixel.net | http://www.facebook.com/SpicyPixel.NET

Comps Owned - ZX.81, ZX.48K, ZX.128K+2, Vic20, C64, Atari-ST, A500.600.1200, PC, Apple Mini-Mac.

spacefractal

Im allready requested this long time ago for the same reason in the request forum. My guess its never been happens, even it's would been nice....
Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation - The beagle Jam - Cave Heroes 2023 - https://spacefractal.itch.io/