I am programming a little space game. I have drawn two space ships to the screen. I want them to act independently of each other.
Code :
void draw_ship()
{
	glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
 
	glColor3f(0.0f,1.0f,0.0f);
	glBegin(GL_LINE_LOOP);
	glVertex3f(-1.5f,-0.25f,0.0f);
	glVertex3f(-1.75f,-0.5f,0.0f);
	glVertex3f(-2.0f,-0.5f,0.0f);
	glVertex3f(-1.5f,0.5f,0.0f);
	glVertex3f(-1.0f,-0.5f,0.0f);
	glVertex3f(-1.25f,-0.5f,0.0f);
	glVertex3f(-1.5f,-0.25f,0.0f);
	glEnd();
 
	glColor3f(1.0f,0.0f,0.0f);
	glBegin(GL_LINE_LOOP);
	glVertex3f(1.5f,-0.25f,0.0f);
	glVertex3f(1.25f,-0.5f,0.0f);
	glVertex3f(1.0f,-0.5f,0.0f);
	glVertex3f(1.5f,0.5f,0.0f);
	glVertex3f(2.0f,-0.5f,0.0f);
	glVertex3f(1.75f,-0.5f,0.0f);
	glVertex3f(1.5f,-0.25f,0.0f);
	glEnd();
 
	glColor3f(1.0f,0.0f,0.0f);
	glPointSize(2.0f);
	glBegin(GL_POINTS);
	glVertex3f(1.5f,up_two++,0.0f);
	glEnd();
 
	glColor3f(0.0f,1.0f,0.0f);
	glPointSize(2.0f);
	glBegin(GL_POINTS);
	glVertex3f(-1.5f,up++,0.0f);
	glEnd();
 
	glutSwapBuffers();
}