Why SPR_update accepts only full struct array? Also why i need to update all of them at once? And its not said anywhere.
If i update one sprite all other go invisible. I wanted atleast to be able to put array together from pointers, but no - its not good enough. I really wanted sprite as part of unit behaviour struct where it can manage its own sprite itself.
Possible others can say whats best way to go with sprite management?
SPR_update annoys me
Moderator: Stef
-
- Very interested
- Posts: 3131
- Joined: Thu Nov 30, 2006 9:46 pm
- Location: France - Sevres
- Contact:
Re: SPR_update annoys me
It should not be a big deal, SPR_Update(..) work that way as it does the VDP resource allocation automatically for you. If you have 5 sprites on screen then just use SPR_Update(sprites, 5);Arrovs wrote:Why SPR_update accepts only full struct array? Also why i need to update all of them at once? And its not said anywhere.
If i update one sprite all other go invisible. I wanted atleast to be able to put array together from pointers, but no - its not good enough. I really wanted sprite as part of unit behaviour struct where it can manage its own sprite itself.
Possible others can say whats best way to go with sprite management?
It can be a bit annoying when you swap a lot of sprite but in this case, just initialize the new ones over older ones and if you want to hide a sprite you can use SPR_setNeverVisible(..) on it so it will be quickly discarded by the engine.
SPR_xxx methods are very high level, they handle many things for you.
If you want lower level access, you may use the methods from vdp_spr instead:
https://github.com/Stephane-D/SGDK/blob ... /vdp_spr.h
Where you directly deal with hardware VDP sprites. SGDK also have a Tile Cache for easier tile allocation in VRAM:
https://github.com/Stephane-D/SGDK/blob ... le_cache.h
Last edited by Stef on Tue Mar 24, 2015 12:57 pm, edited 1 time in total.
Thanks for advice. When i will have time i will look under hood.
For now i wrote struct who have Sprite array, length and occupied array. Every unit just registers for unused sprite in that arry. All others are just made invisible. If im running out of space i can only pray about ram to be able to copy on bigger array. After every frame i say struct to update sprites. Yes i use function pointers in structs so i can feel more OO.
Although i can wish for some things to be better this is best tool around.
For now i wrote struct who have Sprite array, length and occupied array. Every unit just registers for unused sprite in that arry. All others are just made invisible. If im running out of space i can only pray about ram to be able to copy on bigger array. After every frame i say struct to update sprites. Yes i use function pointers in structs so i can feel more OO.
Although i can wish for some things to be better this is best tool around.