Alright, I have this class called ObjectHandler, which pretty much handles all the game objects. A game Object is defined as anything with a loop() and render() function as well as collision functions. The ObjectHandler stores all the Objects in a vector that when you call the ObjectHandler's loop() or render() functions it then calls every Objects loop() or render() functions.
Now, when calling the loop command the ObjectHandler gives itself to the object (like calling Object.loop(ObjectHandler this) so that the Object can use the ObjectHandler to check collisions with all other objects. The problem here is that if I call the ObjectHandler for a collision check I cannot check for specific subclasses of Object without creating separate functions and separate vectors.
So for a gist here's some psuedocode for what I want to do:
bool ObjectHandler::collision(class x)
{
for(int i=0;i<ObjVect.size;i++)
{
if(ObjVect could be considered an x && ObjVect->collision())
{
return true;
}
}
return false;
}
Now of course collision would have a few more variables to pass in, but I believe this gets the point across of what I want to do.
Now I hear there is an easy way of doing this in C#, but I also hear that if you ever have to call a function to tell if a certain object is a certain class then you have design flaws. So I'm wondering if doing it like this is a major flaw in design and would be greatful if you could point me towards some faqs or give some advice if you believe that is the case.