How does SPR_update work with multiple sprites?

SGDK only sub forum

Moderator: Stef

Post Reply
BroOfTheSun
Interested
Posts: 33
Joined: Fri Dec 12, 2014 2:41 am
Location: USA - Chicago, IL

How does SPR_update work with multiple sprites?

Post 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?
Stef
Very interested
Posts: 3131
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Post 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).
BroOfTheSun
Interested
Posts: 33
Joined: Fri Dec 12, 2014 2:41 am
Location: USA - Chicago, IL

Post 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?
Stef
Very interested
Posts: 3131
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Post 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.
BroOfTheSun
Interested
Posts: 33
Joined: Fri Dec 12, 2014 2:41 am
Location: USA - Chicago, IL

Post 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.
Last edited by BroOfTheSun on Tue Dec 30, 2014 7:03 pm, edited 1 time in total.
Stef
Very interested
Posts: 3131
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Post 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.
Post Reply