je comprends pas pk ca fonctionnnne pas

This commit is contained in:
Mylloon 2024-01-08 02:36:47 +01:00
parent e7ffed3005
commit 98fceab42c
Signed by: Anri
GPG key ID: A82D63DFF8D1317F

View file

@ -156,19 +156,33 @@ bool PlateauSafari::deplacementValideCoor(const int x1, const int y1,
Position pos1 = barriere->getPos();
Position pos2 = barriere->getPos2();
/* Conditions si vrai = bloqués */
/* Conditions si vrai = bloqués
* Ordre dans les vérifications :
* - Horizontal/Vertical
* - Sens du déplacement
* - Barrière regardé bien sur la ligne/colonne (2 conditions)
* - Barrière pas derrière nous
* - Si la barrière nous bloque */
// Gauche vers droite
const bool gvd =
y1 == y2 && x1 > x2 && x2 >= std::max(pos1.first, pos2.first);
const bool gvd = y1 == y2 && x1 < x2 && y1 == pos1.second &&
pos1.second == pos2.second &&
x1 < std::max(pos1.first, pos2.first) &&
x2 >= std::max(pos1.first, pos2.first);
// Droite vers gauche
const bool dvg =
y1 == y2 && x1 < x2 && x2 <= std::min(pos1.first, pos2.first);
const bool dvg = y1 == y2 && x1 > x2 && y1 == pos1.second &&
pos1.second == pos2.second &&
x1 > std::min(pos1.first, pos2.first) &&
x2 <= std::min(pos1.first, pos2.first);
// Haut vers bas / Descendre
const bool hvb =
x1 == x2 && y1 < y2 && y2 >= std::max(pos1.second, pos2.second);
const bool hvb = x1 == x2 && y1 < y2 && x1 == pos1.first &&
pos1.first == pos2.first &&
y1 < std::max(pos1.second, pos2.second) &&
y2 >= std::max(pos1.second, pos2.second);
// Bas vers haut / Monter
const bool bvh =
x1 == x2 && y1 > y2 && y2 <= std::min(pos1.second, pos2.second);
const bool bvh = x1 == x2 && y1 > y2 && x1 == pos1.first &&
pos1.first == pos2.first &&
y1 > std::min(pos1.second, pos2.second) &&
y2 <= std::min(pos1.second, pos2.second);
if (d) {
std::cout << std::boolalpha << "barriere " << pos1.first << ","