So, I'm wanting to put enemies into the game soon. In BK1, the way I did the flickering was like this:
Had a thing that got EOR'd each frame. Basically, it made it go like this in terms of sprite order:
0 - Timmy, Timmy's shots, all enemies in sequential order
1 - All enemies, Timmy, Timmy's shots
The main problem with the sequential order is if things get stacked, something will always be invisible.
I was thinking of keeping the routines for drawing stored in memory and then using the EOR'd memory to go to a secondary routine that'd read them in in a different order... for instance, it might go like this:
0 - Timmy, shots, enemies #1-16
1 - Enemies 16-1, Timmy, shots
Does this approach sound reasonable? Thanks.
A better way to scramble the sprites for flickering
Moderator: Moderators
I process all my objects (including the main character) in (pseudo)random order. I get a number from my PRNG and use it to make the index of the first object to process, and then I add some odd number to it (like 7) after each object is done (wrapping back when necessary). It is simple and has worked well so far, but I don't know if that would work well for everybody.
I decided to "randomize" objects rather than individual sprites because I need to be able to stack sprites, I must have some control over their priorities, and this way I full control of the priorities of each object's sprites.
For controlling the priority between different objects I have created 2 virtual layers, and objects that must be on top are rendered to the lower end of the OAM (closer to 0) and low priority ones are rendered to the upper end of the OAM (closer to 63). The OAM gets full when/if both lists meet (although I should let high priority sprites overwrite low priority ones I guess).
I decided to "randomize" objects rather than individual sprites because I need to be able to stack sprites, I must have some control over their priorities, and this way I full control of the priorities of each object's sprites.
For controlling the priority between different objects I have created 2 virtual layers, and objects that must be on top are rendered to the lower end of the OAM (closer to 0) and low priority ones are rendered to the upper end of the OAM (closer to 63). The OAM gets full when/if both lists meet (although I should let high priority sprites overwrite low priority ones I guess).
Having the player see the most recent shot at all times is important for visual feedback to reinforce the connection between the fire button and the shots. So I'd recommend always putting Timmy and the first shot first, and then mixing the other two shots with enemies. Skip through enemies by threes or fives, and cycle through them starting at 0, 1, and 2, or 0, 2, 4, 1, 3.
The really easy way to do OAM cycling:
Whenever you add a sprite to the list, advance 9 sprites (36 bytes).
If after adding a sprite, you end up at the start position, you have transferred 64 sprites, so that's a good time to stop. That's just an 8 bit comparison.
You can also advance the start position by one sprite (4 bytes) every frame.
Only downside to this method is that you lose any form of sprite priority.
Whenever you add a sprite to the list, advance 9 sprites (36 bytes).
If after adding a sprite, you end up at the start position, you have transferred 64 sprites, so that's a good time to stop. That's just an 8 bit comparison.
You can also advance the start position by one sprite (4 bytes) every frame.
Only downside to this method is that you lose any form of sprite priority.
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!