Thank you for the reply ne555.
I have looked into the strategy pattern and it does seem like an intelligent and flexible approach. I will give it a try.
According to what I read, the function pointer approach would be the way to go if I were programming in a language not supporting OOP, such as c.
|¿? Store pointers to the base class.|
I do maintain a vector of base class pointers for the purpose of moving the shots, drawing them and for hit testing against them. I am maintaining separate vectors for each shot class because I recycle the shot instances. Dealing with the actual object class seems necessary when reassigning data members. This approach is proving to be cumbersome though. I may try going with single use shots, where new and delete are used for each shot fired.
EDIT: Wow. I just realized that I'm already using a strategy pattern based approach for the enemy ships motion. Each ship has a Leg* as a data member ( Leg, as in a portion of a path ). Each Leg type defines a move() which implements a different parametrized motion (straight line, circle, etc...). The Leg class has a Leg* nextLeg member and the move() returns this Leg* when the end of a Leg is reached. Ships travel on closed paths this way quite flexibly and automatically. It works great.
I'm not sure why I didn't think of it in the context of shots!