add a second player quad

This commit is contained in:
Josh Holtrop 2013-02-14 23:02:13 -05:00
parent a9ea9216ab
commit 3d05584a7e

View File

@ -25,11 +25,11 @@ void init()
glLoadIdentity();
}
void display(Player p)
void display(Player p1, Player p2)
{
glClear(GL_COLOR_BUFFER_BIT);
glPushMatrix();
glTranslatef(p.x, p.y, 0);
glTranslatef(p1.x, p1.y, 0);
glBegin(GL_QUADS);
glColor3f(1, 0, 0);
glVertex3f(10, 20, 0.0);
@ -38,6 +38,16 @@ void display(Player p)
glVertex3f(10, -20, 0.0);
glEnd();
glPopMatrix();
glPushMatrix();
glTranslatef(p2.x, p2.y, 0);
glBegin(GL_QUADS);
glColor3f(0, 0, 1);
glVertex3f(10, 20, 0.0);
glVertex3f(-10, 20, 0.0);
glVertex3f(-10, -20, 0.0);
glVertex3f(10, -20, 0.0);
glEnd();
glPopMatrix();
SDL_GL_SwapBuffers();
}
@ -48,8 +58,11 @@ int main(char[][] args)
DerelictGLU.load();
Player p1 = new Player();
p1.x = WIDTH / 2;
Player p2 = new Player();
p1.x = WIDTH / 2 - 100;
p1.y = HEIGHT / 2;
p2.x = WIDTH / 2 + 100;
p2.y = HEIGHT / 2;
if (SDL_Init(SDL_INIT_EVERYTHING))
{
@ -81,7 +94,7 @@ int main(char[][] args)
break;
}
}
display(p1);
display(p1, p2);
}
SDL_Quit();