well I have drawn a space ship and bullet and bug sprites to the screen. the one thing I am stuck on is that I want to draw a collision sprite to the screen when a bullet sprite hits a bug sprite and then draws a black sprite to the screen or erases the sprite just hit by a bullet. let me know if you need further explanation of my problem. in the meantime I will continue to work on my problem. thanks in advance for all the help. here is the code I am working with.
void drawScene_two()
{
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, _textureId_eight);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glColor3f(1.0f, 1.0f, 1.0f);
glBegin(GL_POLYGON);
glTexCoord2f(0.0f, 0.0f);
glVertex3f(-0.5f, 1.0f, 0.0f);
glTexCoord2f(1.0f, 0.0f);
glVertex3f(-0.5f, 2.0f, 0.0f);
glTexCoord2f(1.0f, 1.0f);
glVertex3f(0.5f, 2.0f, 0.0f);
glTexCoord2f(0.0f, 1.0f);
glVertex3f(0.5f, 1.0f, 0.0f);
glEnd();
glDisable(GL_TEXTURE_2D);
}
void drawScene_three()
{
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, _textureId_nine);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glColor3f(1.0f, 1.0f, 1.0f);
glBegin(GL_POLYGON);
glTexCoord2f(0.0f, 0.0f);
glVertex3f(-0.5f, 1.0f, 0.0f);
glTexCoord2f(1.0f, 0.0f);
glVertex3f(-0.5f, 2.0f, 0.0f);
glTexCoord2f(1.0f, 1.0f);
glVertex3f(0.5f, 2.0f, 0.0f);
glTexCoord2f(0.0f, 1.0f);
glVertex3f(0.5f, 1.0f, 0.0f);
glEnd();
glDisable(GL_TEXTURE_2D);
}
void collision()
{
sprite object1;
sprite object2;
object1.x = -0.5f;
object1.y = 2.0f;
object1.width = 1.0f;
object1.height = 1.0f;
object2.x = -0.25f+scroll;
object2.y = -7.5f + up;
object2.width = 0.50f+scroll;
object2.height = 0.50f;
if (Sprite_Collide(&object1, &object2) == 1)
{
drawScene_two();
}
}
void collision_two()
{
sprite object3;
sprite object4;
object3.x = -0.5f;
object3.y = 2.0f;
object3.width = 1.0f;
object3.height = 1.0f;
object4.x = -0.25f + scroll;
object4.y = -7.5f + up;
object4.width = 0.50f + scroll;
object4.height = 0.50f;
if (Sprite_Collide(&object3, &object4) == 1)
{
drawScene_three();
}
}
I have tried several things but so far no luck. I have also tried combining the collision detection function into one routine and the drawing routine into one function too.