Quote from: lafouine88 on Mon 07/10/2024 15:48:57I remember one advice from Khris I think who said that most of the time there is a better way than to use 'repeatedly execute' to save RAM.
It's hard to judge the pros and cons without seeing some examples, but creating ~1000 DynamicSprites seems almost certainly like overkill.
I'd probably go with CW's suggestion, but if you ever find yourself in a position where you do need to generate a thousand DynamicSprites, my suggestion would be to not do it all in one go, but do a small number each game cycle. (Assuming that not all the sprites need to be immediately available.)
In this case, since you already have it broken into 10 different functions, I would start by calling them in subsequent game cycles:
int skinUpdateCounter;
void reloadskin(int base, int slot)
{
Skin_stuffed[slot]=base;
skinUpdateCounter=1;
}
void updateSkin()
{
switch(skinUpdateCounter)
{
case 1: AlterEgoNormalView(); break;
case 2: AlterEgoIdleView(); break;
case 3: AlterEgoaoeView(); break;
case 5: AlterEgoatkView(); break;
case 6: AlterEgocryView(); break;
case 7: AlterEgodeathView(); break;
case 8: AlterEgokickView(); break;
case 9: AlterEgosweepView(); break;
case 10:
AlterEgoLHView();
skinUpdateCounter = -1;
break;
}
skinUpdateCounter++;
}
function repeatedly_execute_always()
{
if(skinUpdateCounter>0)
updateSkin();
}
This will spread out the processing over 10 cycles (1/4 second). Since you say it takes 1-2 seconds, this would not be enough, and you would have to handle each of the AlterEgo functions in several steps as well (most easily using a second counter, with some modifications to the counter incrementing logic).