   Sprite Management
    I''m relatively far into making a simple top-down RTS game.  Sprite management has been bothering me, though.  I have a superclass called Sprite, from which different units, and projectiles, derive.  As units create sprites when they engage in combat, how to work with those sprites is becoming a messy issue.   In my update method sprites do a search for other sprites near them.  Then I have a bunch of if''s based on what type of sprite it is to determine what happens next.  This is starting to get out of hand -- I have to search individually for the different sprites.  For example, a tank searches once at 10,000 range for enemies, 400 for incoming shells, and 300 for land mines.  As I add more types of ammunition that list will expand.  There must be a better way to do collision detection.  I also have to use a cumbersome string ID to determine what was detected.  Because of that I can''t put the code in the superclass, and end up repeating a ton of stuff.    If anyone has suggestions for a more organized, and efficient method, I''d greatly appreciate it.Thanks. 
  [ random thoughts ]Well, there's two ways to do it that i see: method one:switch ( unit->GetType() ) {   case BULLET: // whatever   case EXPLOSION: // whatever   ... etc ...   }method 2:unit->Draw();    and let each class handle it's own drawing routine.as regards hit detection, which i have little experience with:My classes have static internal lists that list all objects of that type in existance. Right now, it looks like you are checking the map area for objects around the object in question. The other way is to check objects against each other. This works for lower numbers of objects. if you had many thousands of objects, it may be better to check the map afterall. Unit* a_unit;for ( int i=0; i < Unit::GetNumUnits(); i++ ) { // consult the static list of objects   if ( Unit::GetUnitByIndex(i)->DoesOverlap( a_unit ) ) { a_unit->GetKilled(); }   }    you could make it even cleaner if each type of object had an internal list of objects only of it's type, while the parent class also records it as a generic object. So instead of looking through all Sprite objects for bullets, just look through bullets:Unit* a_unit;for ( int i=0; i < Bullet::GetNumBullets(); i++ ) { // consult the static list of Bullet objects   if ( Bullet::GetBulletByIndex(i)->DoesOverlap( a_unit ) ) { a_unit->GetKilled(); }   }    [edited by - leiavoia on February 15, 2004 10:29:39 PM];  Thanks for the reply.  I like the idea about separate lists for each type of sprite.  That should help quite a bit. 