Page 1 of 1
How does SPR_update work with multiple sprites?
Posted: Sat Dec 27, 2014 10:05 pm
by BroOfTheSun
Do I need to pass in an array of sprite pointers? Or can I make a call to SPR_update for each sprite I want to draw?
Posted: Sat Dec 27, 2014 11:10 pm
by Stef
You need to pass an array of sprite, for instance :
Code: Select all
Sprite sprites[10];
...
SPR_Update(sprites, 2);
and you can call SPR_Update(..) only once per frame.
Your sprite array should contains the active sprites for the frame.
Your array can be 10 in size but you can only send the 2 first sprites to the VDP by using '2' as second argument (as in my example).
Posted: Mon Dec 29, 2014 6:24 am
by BroOfTheSun
So I'm using a function to create the array of sprites. I pass in a list of strings, which go to a table to look up the sprites I want to draw, then add them to the array of sprites. The sprites are already initialized using SPR_initSprite().
This method is giving me an error saying that it is finding re-definitions of the Sprite Definitions, which I set with the SPR_initSprite(). Any ideas what could be going on? Should I not initialize the sprite until I need to draw it?
Posted: Mon Dec 29, 2014 2:53 pm
by Stef
I'm not sure to understand what exactly happen, but you need an static array for SPR_Update(..), i think that may be the issue.
Posted: Mon Dec 29, 2014 5:17 pm
by BroOfTheSun
I was able to figure out the problem. I'm using rescomp to compile my sprites for usage in the program. So I have a gfx.res file to use with rescomp. Somehow, a gfx.s file was in the same folder. I didn't create that file...so I don't know how it ended up there.
Maybe something left over while it was compiling...
EDIT: I interrupted the build while it was compiling, which means the gfx.s wasn't cleaned by make. Lessons learned.
Posted: Tue Dec 30, 2014 11:31 am
by Stef
rescomp actually build the file but it should be cleaned automatically by 'make'. If for some reason a old .s file remains it can indeed bring troubles.