Hi All,
I'm trying to clone space invader, and right now I'm in the step of implemening bullets with base(Green ones) collision.
So I considered each base as a rectangle and a bullet as a rectangle. I have an image that consists of small green pixels, that I want to overdraw as a damage.
I can't come up with an algorithm.. or an idea how to do that
Right now I'm trying to draw the damage bitmap over the hit position of the bullet, but it's not redrawn each frame..
void CheckBulletsBarriersCollision(Ship * ship, vector<Barrier*> barriers, Resources *resources)
{
bool isCollision = false;
CIwSVec2 collisionPoint;
for (vector<Barrier*>::iterator itBarrier = barriers.begin(); itBarrier != barriers.end(); itBarrier++)
{
for (list<Bullet*>::iterator it = ship->Bullets->begin(); it != ship->Bullets->end(); it++)
{
float left = (*it)->Position.x - 5;
float top = (*it)->Position.y - 13;
if (CheckCollision(left, top,
(*itBarrier)->Position.x,
20
, (*itBarrier)->Position.y - (*itBarrier)->mBarrierImage->GetHeight()
, 36))
{
isCollision = true;
collisionPoint.x = left;
collisionPoint.y = top;
break;
}
}
}
if (isCollision)
{
DrawDamage(collisionPoint.x, collisionPoint.y, resources);
}
}