user195257
user195257

Reputation: 3316

'Delete' quad in openGL

im creating a game, my character shoots a bullet, and is going to collide with an enemy, which is drawn like this in display();

glPushMatrix();
        glTranslatef(260, -180, 0.0);
        e[0] = new Platform(0, 0, 0, 40, 40, 40, 40, 0, textures[17], 260, -180);
    glPopMatrix();

How do i go about deleting/not drawing the object once the bullet has collided with it? Im not after code just an idea of how to go about it, thanks!

Upvotes: 0

Views: 424

Answers (2)

Calvin1602
Calvin1602

Reputation: 9547

if ( bullet hits character ){
    listOfCharacters.remove(character)
)

and later :

function drawAllCharacters :
    for each Character in listOfCharacters :
        draw Character

(not sure it's this kind of stuff you want)

Upvotes: 2

Ben Voigt
Ben Voigt

Reputation: 283684

I don't see any draw code there, but the general principle is to conditionally skip the drawing. If you're drawing the quads en masse rather than individually, it may take some work to do that. For example switching from glDrawArrays to glDrawElements allows you to draw only a subset of the quads you've defined.

Upvotes: 1

Related Questions