X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/graphlib.git/blobdiff_plain/d9d083393abda0a28eb718de3000466513aa6b91..acf4714da7838afe963be32f33eca132ad9a1e00:/chateaux/chateaux.cpp diff --git a/chateaux/chateaux.cpp b/chateaux/chateaux.cpp index 7f4d093..b6c26e2 100644 --- a/chateaux/chateaux.cpp +++ b/chateaux/chateaux.cpp @@ -4,6 +4,7 @@ #include #include #include +#include /* Note : les coordonnées réelles vont de -100 à +100 en abscisse, et * de -10 à +140 en ordonnée @@ -165,7 +166,7 @@ void dessineExplosion(DrawingWindow& w, float rx, float ry) w.drawCircle(x, y, i); w.msleep(20); } - w.setColor("white"); + w.setColor("skyblue"); for (i = 0; i < maxray; i++) { w.drawCircle(x, y, i); w.msleep(10); @@ -200,10 +201,16 @@ void initialise(DrawingWindow& w) largeurMont = frand(largeurMin, largeurMax); hauteurMont = frand(hauteurMin, hauteurMax); wnd = frand(-30, 30); + w.setBgColor("skyblue"); w.clearGraph(); dessineTerrain(w, largeurMont, hauteurMont); dessineChateau(w, positionChateau1); dessineChateau(w, positionChateau2); + w.setColor("wheat"); + w.drawText(rtowX(w, positionChateau1), rtowY(w, 0) + 8, "Joueur 1", + Qt::AlignHCenter); + w.drawText(rtowX(w, positionChateau2), rtowY(w, 0) + 8, "Joueur 2", + Qt::AlignHCenter); dessineVent(w, wnd); } @@ -234,7 +241,7 @@ int tir(DrawingWindow& w, vy += ay * dt; w.msleep(10); - w.setColor("white"); + w.setColor("skyblue"); w.fillCircle(wx, wy, 2); // w.setColor("black"); // w.drawPoint(wx, wy); @@ -296,12 +303,17 @@ int jeu1(DrawingWindow& w) dessineVent(w, wnd); } while (!perdant); dessineFlammes(w, x, y); - std::cout << "Joueur " << perdant; + std::stringstream msg; + msg << "Joueur " << perdant; if (perdant == joueur) - std::cout << " s'est suicidé"; + msg << " s'est suicidé !"; else - std::cout << " a perdu"; - std::cout << " !\n"; + msg << " a perdu !"; + w.setColor("darkred"); + w.setBgColor("white"); + w.drawTextBg(w.width / 2, w.height / 3, msg.str().c_str(), + Qt::AlignCenter); + std::cout << msg.str() << "\n"; return perdant; } @@ -321,8 +333,10 @@ void jeu(DrawingWindow& w) w.sleep(2); else { char r; - std::cout << "Recommencer (o/n) ? "; - std::cin >> r; + do { + std::cout << "Recommencer (o/n) ? "; + std::cin >> r; + } while (std::cin.good() && r != 'o' && r != 'n'); rejouer = r == 'o'; } } while (rejouer);