static void display(void) { // clear the scene glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glPushMatrix(); if (tank1.GetLife() > 0 && tank2.GetLife() > 0) { tank1.Draw(); tank2.Draw(); tank1.DrawAllBullets(); tank2.DrawAllBullets(); for (list<CPrzeszkoda *>::iterator it = przeszkoda.begin(); it != przeszkoda.end(); it++) { (*it)->Draw(); } boost.Draw(); } else { glRasterPos2i(0, 0); glColor3f(1, 0, 0); unsigned char tekst[] = "Koniec gry"; glutBitmapString(GLUT_BITMAP_HELVETICA_18, tekst); } glPopMatrix(); glutSwapBuffers(); }
void keyboard(unsigned char key, int x, int y)//poszukac czegos na wzor qt { if (tank1.GetLife() > 0 && tank2.GetLife() > 0) { //przód if (key == 'w') { tank1.Move(0, +0.1, 0); } if (key == 'i') { tank2.Move(0, +0.1, 0); } //ty³ if (key == 's') { tank1.Move(0, -0.1, 0); } if (key == 'k') { tank2.Move(0, -0.1, 0); } //prawo if (key == 'd') { tank1.switchAngle(-5); } if (key == 'l') { tank2.switchAngle(-5); } //lewo if (key == 'a') { tank1.switchAngle(5); } if (key == 'j') { tank2.switchAngle(5); } // zmiana mocy pocisku dla czolgu pierwszego if (key == 'q') { tank1.ChangeBulletPower(1); std::cout << "Bullet power: " << tank1.GetBulletPower() << std::endl; } else if (key == 'z') { tank1.ChangeBulletPower(-1); std::cout << "Bullet power: " << tank1.GetBulletPower() << std::endl; } // strzal dla czolgu pierwszego else if (key == 'e') { tank1.FireBullet(); } // si³a pocisku drugiego if (key == 'u') { tank2.ChangeBulletPower(1); std::cout << "Bullet power: " << tank2.GetBulletPower() << std::endl; } else if (key == 'n') { tank2.ChangeBulletPower(-1); std::cout << "Bullet power: " << tank2.GetBulletPower() << std::endl; } // strzal drugiego pocisku else if (key == 'o') { tank2.FireBullet(); } } }