high,
i have a class caled Entity. Entity contains xPosition, yPosition, xVelocity, yVelocity, width, height.
i have 3 other classes, Player, Enemy, and Bullets. these 3 classes inherit from Entity. of course they each have their own properties like Update(), or image, ETC.
now, i want to start doing collision detection for the bulltes against the players. could i write:
bool BulletCollision(Entity &target1, Entity &bullet); // or even could have done Bullet &bullet for the second parameter
would this work? OR, would i have to do:
bool PlyrBulletCollision(Player &player, Bullets &bullet);
bool EnmyBulletCollision(Enemy &enemy, Bullets &bullet);
do you see what im doing here? i guess what im asking is, what kind of tricks can i pull if i inherit from a class? im really new to this inheritense stuff, but i can swear i remember there being "tricks" where you could call a Player Entity instead, or call a Enemy Entity. i KNOW there are tricks like this available, could anyone inform me of any of them? what about doing this:
Entity myentities[2];
Player player;
Enemy enemy;
myentities[0] = player;
myentities[1] = enemy;
for(int i = 0; i < 2; i++)
{
if(entities.xPos == entities.xPos)
the enemy and player have the same xPosition!!
}
</pre>
do you see what im getting at? i think some things like this are possible, i just dont know what. thanks for any help!!
</i>