A
lgorithmique
N
umérique
D
istribuée
Public GIT Repository
projects
/
graphlib.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
.
[graphlib.git]
/
chateaux
/
chateaux.cpp
diff --git
a/chateaux/chateaux.cpp
b/chateaux/chateaux.cpp
index
de2f469
..
16f10e2
100644
(file)
--- a/
chateaux/chateaux.cpp
+++ b/
chateaux/chateaux.cpp
@@
-33,6
+33,8
@@
const float k = 0.005;
const float dt = 0.05;
int nbJoueurs = 2;
const float dt = 0.05;
int nbJoueurs = 2;
+int score1 = 0;
+int score2 = 0;
float largeurMont;
float hauteurMont;
float largeurMont;
float hauteurMont;
@@
-171,7
+173,7
@@
void dessineExplosion(DrawingWindow& w, float rx, float ry)
w.drawCircle(x, y, i);
w.msleep(10);
}
w.drawCircle(x, y, i);
w.msleep(10);
}
- w.fillCircle(x, y, maxray - 1);
+
//
w.fillCircle(x, y, maxray - 1);
}
void dessineFlammes(DrawingWindow& w, float x0, float y0)
}
void dessineFlammes(DrawingWindow& w, float x0, float y0)
@@
-204,6
+206,7
@@
void initialise(DrawingWindow& w)
w.setBgColor("skyblue");
w.clearGraph();
dessineTerrain(w, largeurMont, hauteurMont);
w.setBgColor("skyblue");
w.clearGraph();
dessineTerrain(w, largeurMont, hauteurMont);
+ dessineVent(w, wnd);
dessineChateau(w, positionChateau1);
dessineChateau(w, positionChateau2);
w.setColor("wheat");
dessineChateau(w, positionChateau1);
dessineChateau(w, positionChateau2);
w.setColor("wheat");
@@
-211,7
+214,10
@@
void initialise(DrawingWindow& w)
Qt::AlignHCenter);
w.drawText(rtowX(w, positionChateau2), rtowY(w, 0) + 8, "Joueur 2",
Qt::AlignHCenter);
Qt::AlignHCenter);
w.drawText(rtowX(w, positionChateau2), rtowY(w, 0) + 8, "Joueur 2",
Qt::AlignHCenter);
- dessineVent(w, wnd);
+ std::stringstream s;
+ s << score1 << " / " << score2;
+ w.drawText(rtowX(w, 0), rtowY(w, 0) + 8, s.str().c_str(),
+ Qt::AlignHCenter);
}
/* Retour : numéro du perdant, 0 sinon
}
/* Retour : numéro du perdant, 0 sinon
@@
-241,6
+247,7
@@
int tir(DrawingWindow& w,
vy += ay * dt;
w.msleep(10);
vy += ay * dt;
w.msleep(10);
+// w.sync();
w.setColor("skyblue");
w.fillCircle(wx, wy, 2);
// w.setColor("black");
w.setColor("skyblue");
w.fillCircle(wx, wy, 2);
// w.setColor("black");
@@
-274,6
+281,7
@@
int jeu1(DrawingWindow& w)
do {
joueur = 3 - joueur;
do {
joueur = 3 - joueur;
+ w.sync();
std::cout << "-=| Joueur " << joueur << " |=-";
float alpha;
std::cout << "-=| Joueur " << joueur << " |=-";
float alpha;
@@
-286,7
+294,8
@@
int jeu1(DrawingWindow& w)
} else {
alpha = frand(10, 90);
v0 = frand(10, 100);
} else {
alpha = frand(10, 90);
v0 = frand(10, 100);
- std::cout << " [ " << alpha << " ; " << v0 << " ]\n";
+ std::cout << " [ " << (int )alpha << "° ; " << (int )v0 << " ]"
+ << std::endl;
}
alpha = deg2rad(alpha);
}
alpha = deg2rad(alpha);
@@
-304,23
+313,22
@@
int jeu1(DrawingWindow& w)
} while (!perdant);
dessineFlammes(w, x, y);
std::stringstream msg;
} while (!perdant);
dessineFlammes(w, x, y);
std::stringstream msg;
- msg << "Joueur " << perdant;
+ msg << "
Joueur " << perdant;
if (perdant == joueur)
if (perdant == joueur)
- msg << " s'est suicidé !";
+ msg << " s'est suicidé !
";
else
else
- msg << " a perdu !";
+ msg << " a perdu !
";
w.setColor("darkred");
w.setBgColor("white");
w.drawTextBg(w.width / 2, w.height / 3, msg.str().c_str(),
Qt::AlignCenter);
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";
+ w.sync();
+ std::cout << msg.str() << std::endl;
return perdant;
}
void jeu(DrawingWindow& w)
{
return perdant;
}
void jeu(DrawingWindow& w)
{
- int score1 = 0;
- int score2 = 0;
bool rejouer = true;
do {
int perdant = jeu1(w);
bool rejouer = true;
do {
int perdant = jeu1(w);
@@
-328,7
+336,8
@@
void jeu(DrawingWindow& w)
score2++;
else if (perdant == 2)
score1++;
score2++;
else if (perdant == 2)
score1++;
- std::cout << "### SCORE : " << score1 << " / " << score2 << " ###\n";
+ std::cout << "### SCORE : " << score1 << " / " << score2 << " ###"
+ << std::endl;
if (nbJoueurs == 0)
w.sleep(2);
else {
if (nbJoueurs == 0)
w.sleep(2);
else {