-static void display(void) {
- glClear(GL_COLOR_BUFFER_BIT);
- glColor3d(0.0, 0.0, 0.0);
+static void timer(int lastTime) {
+ if(state == STATE_UI) {
+ return;
+ }
+
+ int curTime = glutGet(GLUT_ELAPSED_TIME);
+ do {
+ lastTime += FRAME;
+ run();
+ } while(lastTime + FRAME < curTime);
+ glutPostRedisplay();
+ glutTimerFunc(FRAME - (curTime - lastTime), timer, curTime);
+}
+
+static void startGame(void) {
+ glutTimerFunc(FRAME, timer, glutGet(GLUT_ELAPSED_TIME));
+ initBall();
+}
+
+static void drawText(double x, double y, char* str) {
+ glRasterPos2d(x, y);
+ while(*str) {
+ glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18, *str);
+ ++str;
+ }
+}
+
+static void menuDisplay(void) {
+ drawText(-20, 50, "Awesome PONG!");
+ drawText(-50, -50, "Press 1 for a single player game.");
+ drawText(-50, -60, "Press 2 for a multi player game.");
+ drawText(-50, -70, "Keys: w/s and i/k");
+ drawText(-20, 0, menu);
+}