+ float vxr = vx - wnd;
+ float kvr = -k * sqrt(vxr * vxr + vy * vy);
+ float ax = kvr * vxr;
+ float ay = kvr * vy - g;
+ x += vx * dt;
+ y += vy * dt;
+ vx += ax * dt;
+ vy += ay * dt;
+
+ w.msleep(10);
+// w.sync();
+ w.setColor("skyblue");
+ w.fillCircle(wx, wy, 2);
+// w.setColor("black");
+// w.drawPoint(wx, wy);
+
+ if (y <= 0) {
+ collision = 3;
+ } else if (y < hauteurChateau) {
+ if (positionChateau1 - largeurChateau <= x
+ && positionChateau1 + largeurChateau >= x)
+ collision = 1;
+ else if (positionChateau2 - largeurChateau <= x
+ && positionChateau2 + largeurChateau >= x)
+ collision = 2;
+ }
+ if (!collision) {
+ float h = hauteurMontagne(largeurMont, hauteurMont, x);
+ if (h > 0 && y < h)
+ collision = 3;
+ }
+ } while (!collision);
+ return collision == 3 ? 0 : collision;
+}
+
+int jeu1(DrawingWindow& w)
+{
+ initialise(w);
+ int joueur = 2;
+ float x, y;
+ int perdant;
+ do {
+ joueur = 3 - joueur;
+
+ w.sync();
+ std::cout << "-=| Joueur " << joueur << " |=-";
+
+ float alpha;
+ float v0;
+ if (joueur <= nbJoueurs) {
+ std::cout << "\nangle ? ";
+ std::cin >> alpha;
+ std::cout << "vitesse initiale ? ";
+ std::cin >> v0;
+ } else {
+ alpha = frand(10, 90);
+ v0 = frand(10, 100);
+ std::cout << " [ " << (int )alpha << "° ; " << (int )v0 << " ]"
+ << std::endl;
+ }
+
+ alpha = deg2rad(alpha);
+ float x0;
+ if (joueur == 1) {
+ x0 = positionChateau1 + 0.8 * largeurChateau;
+ } else {
+ x0 = positionChateau2 - 0.8 * largeurChateau;
+ alpha = PI - alpha;
+ }
+ float y0 = hauteurChateau + 1;
+ perdant = tir(w, x0, y0, v0, alpha, x, y);
+ dessineExplosion(w, x, y);
+ dessineVent(w, wnd);
+ } while (!perdant);
+ dessineFlammes(w, x, y);
+ std::stringstream msg;
+ msg << " Joueur " << perdant;
+ if (perdant == joueur)
+ msg << " s'est suicidé ! ";
+ else
+ msg << " a perdu ! ";
+ w.setColor("darkred");
+ w.setBgColor("white");
+ w.drawTextBg(w.width / 2, w.height / 3, msg.str().c_str(),
+ Qt::AlignCenter);
+ w.sync();
+ std::cout << msg.str() << std::endl;
+ return perdant;
+}
+
+void jeu(DrawingWindow& w)
+{
+ bool rejouer = true;
+ do {
+ int perdant = jeu1(w);
+ if (perdant == 1)
+ score2++;
+ else if (perdant == 2)
+ score1++;
+ std::cout << "### SCORE : " << score1 << " / " << score2 << " ###"
+ << std::endl;
+ if (nbJoueurs == 0)
+ w.sleep(2);
+ else {
+ char r;
+ do {
+ std::cout << "Recommencer (o/n) ? ";
+ std::cin >> r;
+ } while (std::cin.good() && r != 'o' && r != 'n');
+ rejouer = r == 'o';
+ }
+ } while (rejouer);
+ w.closeGraph();