Disable automatic animations for statically loaded sprites

SGDK only sub forum

Moderator: Stef

Post Reply
masteries
Very interested
Posts: 53
Joined: Thu Jul 30, 2020 3:33 pm

Disable automatic animations for statically loaded sprites

Post by masteries » Wed Dec 08, 2021 1:20 pm

Greetings,

This thread is related to a problem I am facing animating statically loaded sprites;

Sprites that are loaded using "SPR_loadAllFrames()" function;

for the rest of sprites, we can call them dinamically loaded ones (due to only a single frame is loaded in VRAM at a time),
the "SPR_SetFrame()" function works ok.

Dinamically sprites are declared in this way using "sprite.res" (all sprites are presented in a single row):

SPRITE ebody_asset "sprite/16c/ebodyf_4x3.bmp" 4 3 NONE 0

A zero is set, due to automatic animation is not desire; sprite tick functions are shared (not 100% possible) with their Atari STE version counterparts, where animation is based in change the frame to show explicitly, such "SPR_SetFrame()" function does.


But statically loaded sprites, such grenade sprite (that takes only 12 tiles) are declared in the same way (all sprites are presented in a single row):

SPRITE grenade_asset "sprite/16c/grenade_2x2.bmp" 2 2 BEST 0

FYI: Due to these are full loaded into VRAM, BEST compression is suitable for them,


But despite I tried code like this:

Code: Select all


	sprTileIndexes[0] = SPR_loadAllFrames(&grenade_asset, 1600, NULL);
	
	...
	
	
	//Further in the game code
	
	id = EntitySpawn(EntityType_EGRENADE,x_location,y_location);
	
        ...
        
        //At enemies grenade tick function
        
	TileIndex = sprTileIndexes[0][entidad[id].spr->animInd][entidad[id].frame];
	//Obviously id is the number retrieved with EntitySpawn function
	SPR_setVRAMTileIndex(entidad[id].spr,TileIndex);

entidad[id].frame changes have no effect at all,

only if I declare these static loaded sprites such:

SPRITE grenade_asset "sprite/16c/grenade_2x2.bmp" 2 2 BEST 1 //or 2... 3


the sprite is being automatically animated, but its not the desired behaviour;
due to a lost of control and similarity with already written tick function code.


Thanks in advance,

Stef
Very interested
Posts: 3131
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Re: Disable automatic animations for statically loaded sprites

Post by Stef » Wed Dec 08, 2021 10:13 pm

I'm not sure of what you're doing exactly.
You said you have all your sprites are presented in a single row ? I don't understand, that means the sprite->animInd is always 0 ?
Also "statically" loaded sprites also require the use of setFrame(..) method at same time you're doing the setVRAMTileIndex(..)

masteries
Very interested
Posts: 53
Joined: Thu Jul 30, 2020 3:33 pm

Re: Disable automatic animations for statically loaded sprites

Post by masteries » Fri Dec 10, 2021 5:29 pm

Stef wrote:
Wed Dec 08, 2021 10:13 pm
I'm not sure of what you're doing exactly.
You said you have all your sprites are presented in a single row ? I don't understand, that means the sprite->animInd is always 0 ?
Also "statically" loaded sprites also require the use of setFrame(..) method at same time you're doing the setVRAMTileIndex(..)
You understood it right :)

sprite->animInd will need to be zero (never checked), due to there are no rows at sprite sheet,

I think I lack the usage of SPR_setFrame() with these "statically" loaded sprites,
Thanks Stef!

I´ll report asap, due to I am currently fixing other major things

Stef
Very interested
Posts: 3131
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Re: Disable automatic animations for statically loaded sprites

Post by Stef » Tue Dec 14, 2021 8:14 pm

Well, that shouldn't give specific troubles, as soon you use the setVRAMTileIndex(..) according to it.
But if your sprite sheet only use a single row, be careful to not use more than 256 frames then.

Post Reply