I post whole code as attachment
With 2 enemies and the player on screen there is already an noticeable slowdown, I am just using the usual spr_setanim, spr_setframe.. nothing very fancy. And if I put 4 enemies on screen + explosions the game freezes :/. 3 or less enemies work just fine.
video crash:
https://www.youtube.com/watch?v=4jyqMKbeMg0
Here is how I am initializing the engine:
Code: Select all
SYS_disableInts();
VDP_setScreenHeight224();
VDP_setScreenWidth320();
SPR_initEx(16, 256, 256);
SYS_enableInts();
Code: Select all
SetupSystem();
LevelManagerInit();
while (TRUE)
{
JoypadManager_UpdateJoypad();
LevelManagerUpdate();
SPR_update();
VDP_waitVSync();
}
return 0;
I also have some other questions regarding best practices width SGDK:
1) I add sprites (via SPR_addSprite) and release(SPR_releaseSprite) everytime an object bounding box gets inside/outside of the screen. I noticed there is an AUTO_VISIBILITY flag, but that didnt seem to work for me, is there anything especial you have to do?
2) I am using VDP_setMapEx, is this the best to do the scrolling? I saw other topics that there other methods, but not sure if there is a difference perfomance wise?