PDA

View Full Version : space wars



pbivens
04-23-2014, 10:13 PM
I am making a simple space invaders/asteroids game using opengl and c++. I am still using some deprecated functions. I have got my game to move a spaceship across the bottom of the screen and to shoot bullets at the top of the screen. I want to have an asteroid to move from the top of the screen to the bottom of the screen independently of the space ship or the bullets. I have got the asteroid to move from the top of the screen to the bottom of the screen however it causes the space ship to flicker and unable to move and the bullet too. here is the code I am working on.


void drawScene_two()
{
while (x <= 150)
{
glClear(GL_DEPTH_BUFFER_BIT);

glMatrixMode(GL_MODELVIEW);
glLoadIdentity();

glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, _textureId_three);

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(-1.0f, 8.0f - down, 0.0f);
glTexCoord2f(1.0f, 0.0f);
glVertex3f(-1.0f, 10.0f - down, 0.0f);
glTexCoord2f(1.0f, 1.0f);
glVertex3f(1.0f, 10.0f - down, 0.0f);
glTexCoord2f(0.0f, 1.0f);
glVertex3f(1.0f, 8.0f - down, 0.0f);
glEnd();

down += 0.1f;

glDisable(GL_TEXTURE_2D);

glutSwapBuffers();

x++;
}
}

let me know if you need more code or information.