Implementation Question

Im working on a game engine. I am unsure about how to implement physics based sprites and non-physics based sprites together.

In the game some things are controlled by physics, mostly the playable characters and explosions. I also have some things that don't need all the features of the engine, for instance, a swarm of bees which don't need mass or friction to model correctly but do need to be able to detect collisions with walls. It seemed silly to add all the extra overhead of b2Body for the bees.

So right now all physics sprites inherit from PhysSprite, and simpler things (like the bees) from SimpleSprite.

In my drawing code I currently check to see what kind of sprite it is, because the way the positioning is handled in both classes is different. Below is some pseudo code.

var position:b2Vec2;
if(sprite is PhysSprite){
position = sprite.body.GetPosition();
}
else if(sprite is SimpleSprite){
position = sprite.GetPosition();
}
canvas.draw(sprite.bitmapdata, position.x, position.y);

This seems like an awkward way to do things. I find myself adding these kinds of conditionals in lots of places in the code to handle the different ways the position information is accessed. Is there a better way to do this?

Additionally, I know b2world handles the collision detection. Since the SimpleSprite isnt simulated in b2world, whats the best way to handle collisions with wall geometry?
Learn about Polymorphism. Basically, have the two sprite inherit from an abstract parent.

Or you could just use bodies and shapes for everything. Just set the "simple" stuff to be sensors. I don't think it'll really be *that* much of a drag, but I guess it depends on your game.

Original thread: https://box2d.org/forum/viewtopic.php?t=1905