News:

Building a 3D Ray Tracer  By stevmjon

Main Menu

Sprite Locals

Started by kevin, May 26, 2004, 08:41:47 PM

Previous topic - Next topic

kevin

Figured I'd make an example of this, since I'm guessing  it's somewhat been overlooked... :)

You'll notice that with rather minimal effort you could write your games and not use any array(s) or lists, but store everything within your sprites  local region.  So it's a slight inversion of the normal approach.

Sprites 'in use' form a linked list, like everything else, but only these are exposed.   So there's a few commands to run through the list. GetFirstSprite(), PreviousSprite(CurrentSprite) NextSprite(CurrentSprite) and that's about it.  That's all you need :)

It's important to note that Next/previous Sprite(CurrentSprite)   take you to next/previous sprite in the list, from the sprite index you pass it.   If the index you give it is deleted, you'll end up traversing the Free elements rather than the allocation sprites list.   The end of the list is denoted with a -1 value.  


Anyway, simple but effective :)