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
Add some words on installation.
[graphlib.git]
/
chateaux
/
chateaux.cpp
diff --git
a/chateaux/chateaux.cpp
b/chateaux/chateaux.cpp
index
16f10e2
..
6ad81b7
100644
(file)
--- a/
chateaux/chateaux.cpp
+++ b/
chateaux/chateaux.cpp
@@
-6,8
+6,8
@@
#include <cstdlib>
#include <sstream>
#include <cstdlib>
#include <sstream>
-/* Note : les coordonn
ées réelles vont de -100 à
+100 en abscisse, et
- * de -10
à +140 en ordonné
e
+/* Note : les coordonn
ées réelles vont de -100 à
+100 en abscisse, et
+ * de -10
à +140 en ordonné
e
*/
const float PI = 4.0 * atan(1.0);
*/
const float PI = 4.0 * atan(1.0);
@@
-22,6
+22,8
@@
const float hauteurMax = 130;
const float largeurMin = 40;
const float largeurMax = 150;
const float largeurMin = 40;
const float largeurMax = 150;
+const float ventMax = 30;
+
const float largeurChateau = 8.5;
const float hauteurChateau = 7;
const float largeurChateau = 8.5;
const float hauteurChateau = 7;
@@
-40,8
+42,8
@@
float largeurMont;
float hauteurMont;
float wnd;
float hauteurMont;
float wnd;
-/* Retourne un nombre pseudo-al
éatoire compris entre 0 et le paramè
tre
- * 'max' (exclus)
+/* Retourne un nombre pseudo-al
éatoire compris entre le paramè
tre
+ * 'm
in' (inclus) et le paramètre 'm
ax' (exclus)
*/
float frand(float min, float max)
{
*/
float frand(float min, float max)
{
@@
-58,26
+60,26
@@
float deg2rad(float deg)
return deg * PI / 180.0;
}
return deg * PI / 180.0;
}
-// conversion coordonn
ées réelles -> coordonnées fenê
tre
+// conversion coordonn
ées réelles -> coordonnées fenê
tre
int rtowX(const DrawingWindow& w, float rx)
{
int rtowX(const DrawingWindow& w, float rx)
{
- return (int )roundf(
w.width * (rx - rXMin) / (rXMax - rXMin + 1.0
));
+ return (int )roundf(
(w.width - 1) * (rx - rXMin) / (rXMax - rXMin
));
}
int rtowY(const DrawingWindow& w, float ry)
{
}
int rtowY(const DrawingWindow& w, float ry)
{
- return (int )roundf(
w.height * (rYMax - ry) / (rYMax - rYMin + 1.0
));
+ return (int )roundf(
(w.height - 1) * (rYMax - ry) / (rYMax - rYMin
));
}
}
-// conversion coordonn
ées réelles -> coordonnées fenêtre
+// conversion coordonn
ées fenêtre -> coordonnées réelles
float wtorX(const DrawingWindow& w, int wx)
{
float wtorX(const DrawingWindow& w, int wx)
{
- return (rXMax - rXMin
+ 1.0) * wx / w.width
+ rXMin;
+ return (rXMax - rXMin
) * wx / (w.width - 1)
+ rXMin;
}
float wtorY(const DrawingWindow& w, int wy)
{
}
float wtorY(const DrawingWindow& w, int wy)
{
- return -(rYMax - rYMin
+ 1.0) * wy / w.height -
rYMax;
+ return -(rYMax - rYMin
) * wy / (w.height - 1) +
rYMax;
}
float hauteurMontagne(float largeur, float hauteur, float x)
}
float hauteurMontagne(float largeur, float hauteur, float x)
@@
-202,7
+204,7
@@
void initialise(DrawingWindow& w)
{
largeurMont = frand(largeurMin, largeurMax);
hauteurMont = frand(hauteurMin, hauteurMax);
{
largeurMont = frand(largeurMin, largeurMax);
hauteurMont = frand(hauteurMin, hauteurMax);
- wnd = frand(-
30, 30
);
+ wnd = frand(-
ventMax, ventMax
);
w.setBgColor("skyblue");
w.clearGraph();
dessineTerrain(w, largeurMont, hauteurMont);
w.setBgColor("skyblue");
w.clearGraph();
dessineTerrain(w, largeurMont, hauteurMont);
@@
-216,12
+218,12
@@
void initialise(DrawingWindow& w)
Qt::AlignHCenter);
std::stringstream s;
s << score1 << " / " << score2;
Qt::AlignHCenter);
std::stringstream s;
s << score1 << " / " << score2;
- w.drawText(rtowX(w, 0), rtowY(w, 0) + 8, s.str()
.c_str()
,
+ w.drawText(rtowX(w, 0), rtowY(w, 0) + 8, s.str(),
Qt::AlignHCenter);
}
Qt::AlignHCenter);
}
-/* Retour : num
é
ro du perdant, 0 sinon
- x et y contiennent les coordonn
é
es de la collision
+/* Retour : num
é
ro du perdant, 0 sinon
+ x et y contiennent les coordonn
é
es de la collision
*/
int tir(DrawingWindow& w,
float x0, float y0, float v0, float alpha, float& x, float &y)
*/
int tir(DrawingWindow& w,
float x0, float y0, float v0, float alpha, float& x, float &y)
@@
-294,7
+296,7
@@
int jeu1(DrawingWindow& w)
} else {
alpha = frand(10, 90);
v0 = frand(10, 100);
} else {
alpha = frand(10, 90);
v0 = frand(10, 100);
- std::cout << " [
" << (int )alpha << "
° ; " << (int )v0 << " ]"
+ std::cout << " [
" << (int )alpha << "Â
° ; " << (int )v0 << " ]"
<< std::endl;
}
<< std::endl;
}
@@
-315,12
+317,12
@@
int jeu1(DrawingWindow& w)
std::stringstream msg;
msg << " Joueur " << perdant;
if (perdant == joueur)
std::stringstream msg;
msg << " Joueur " << perdant;
if (perdant == joueur)
- msg << " s'est suicid
é
! ";
+ msg << " s'est suicid
é
! ";
else
msg << " a perdu ! ";
w.setColor("darkred");
w.setBgColor("white");
else
msg << " a perdu ! ";
w.setColor("darkred");
w.setBgColor("white");
- w.drawTextBg(w.width / 2, w.height / 3, msg.str()
.c_str()
,
+ w.drawTextBg(w.width / 2, w.height / 3, msg.str(),
Qt::AlignCenter);
w.sync();
std::cout << msg.str() << std::endl;
Qt::AlignCenter);
w.sync();
std::cout << msg.str() << std::endl;