Theorical question about the sprites
Posted: Thu Oct 15, 2015 9:18 am
Hi,
I have question about sprites list.
1) What I want to do : Have one sprite for my player and sprites for enemies.
I don't know how the sprite_eng really work. I read the source and find all information about the sprites list.
In code, I have two arrays :
For the update, can I do that ?
The problem is that I haven't already init all my enemy sprite. Do I need an other variable to know how much enemy I have created ?
I use ENN_MAX and NB_PLAYER because I know sometime I'll have 32 pixel sprites or 48 pixels sprites. And 48 pixels mean 2 sprites.
2) When I testing collide between player sprite and enemy sprites. I test all enemy sprite with my player. Enemy DIE when he collide. All I know is the number Inside the enn_spr[ENN_MAX] array. Can I use SPR_clear("Number to delete") ?
3) If I delete a enemy sprite, can I always use the SPR_update(enn_spr, ENN_MAX); when we know that a sprite is missing ?
For exemple I have 10 enemies, I kill the number 3. I have only 9 sprites but with the hole in the center of the 10 values array. So I will not test the collide when I test the 9 sprites : enn_spr[2] is empty.
Thanks in advance.
I have question about sprites list.
1) What I want to do : Have one sprite for my player and sprites for enemies.
I don't know how the sprite_eng really work. I read the source and find all information about the sprites list.
In code, I have two arrays :
Code: Select all
//sprite for ennemy
Sprite enn_spr[ENN_MAX];
// sprites player
Sprite sprites[NB_PLAYER];
Code: Select all
SPR_update(sprites, Nb_PLAYER);
SPR_update(enn_spr, ENN_MAX);
I use ENN_MAX and NB_PLAYER because I know sometime I'll have 32 pixel sprites or 48 pixels sprites. And 48 pixels mean 2 sprites.
2) When I testing collide between player sprite and enemy sprites. I test all enemy sprite with my player. Enemy DIE when he collide. All I know is the number Inside the enn_spr[ENN_MAX] array. Can I use SPR_clear("Number to delete") ?
3) If I delete a enemy sprite, can I always use the SPR_update(enn_spr, ENN_MAX); when we know that a sprite is missing ?
For exemple I have 10 enemies, I kill the number 3. I have only 9 sprites but with the hole in the center of the 10 values array. So I will not test the collide when I test the 9 sprites : enn_spr[2] is empty.
Thanks in advance.