Skip to content
Snippets Groups Projects
Commit b30ba150 authored by Azurlors's avatar Azurlors
Browse files

Update

parent a542c81e
No related branches found
No related tags found
No related merge requests found
......@@ -9,7 +9,6 @@ import environnement.HitBox;
import map.Obstacle;
import environnement.Physique;
import jeu.Jeu;
import jeu.Painter;
public class Character extends Entity{
......@@ -130,7 +129,8 @@ public class Character extends Entity{
obsMin = obs;
}
}
}obstacleBeneath = obsMin;
}
obstacleBeneath = obsMin;
}
/*public void checkIfNextToWall(HashMap<String,Boolean> collisionMap){
......
......@@ -47,23 +47,35 @@ public class HitBox {
public static HashMap<String,Boolean> collisionMap(HitBox A, HitBox B){ // lignes sautées pour raison de lisibilité
HashMap<String,Boolean> map = new HashMap<>();
Boolean a = !(A.extremites.get("HautGauche").getX() > B.extremites.get("HautDroite").getX()); // A est à droite de B
Boolean b = !(A.extremites.get("HautDroite").getX() < B.extremites.get("HautGauche").getX()); // A est à gauche de B
Boolean c = !(A.extremites.get("HautGauche").getZ() > B.extremites.get("BasGauche").getZ()); // A est en dessous de B
Boolean d = !(A.extremites.get("BasGauche").getZ() < B.extremites.get("HautGauche").getZ()); // A est au dessus de B
map.put("collision_gauche",a);
map.put("collision_droite",b);
map.put("collision_bas",c);
map.put("collision_haut",d);
map.put("collision_gauche", false);
map.put("collision_droite", false);
map.put("collision_bas", false);
map.put("collision_haut", false);
boolean a = !(A.extremites.get("HautGauche").getX() > B.extremites.get("HautDroite").getX()); // A est à droite de B
boolean b = !(A.extremites.get("HautDroite").getX() < B.extremites.get("HautGauche").getX()); // A est à gauche de B
boolean c = !(A.extremites.get("HautGauche").getZ() > B.extremites.get("BasGauche").getZ()); // A est en dessous de B
boolean d = !(A.extremites.get("BasGauche").getZ() < B.extremites.get("HautGauche").getZ()); // A est au dessus de B
if (a && !d && !c){
map.put("collision_gauche", true);
}
else if (b && !d && !c) {
map.put("collision_droite", true);
}
else if (c && !a && !b) {
map.put("collision_bas", true );
}
else if (d && !a && !b) {
map.put("collision_haut", true);
}
return map;
}
public static Boolean collision(HitBox A, HitBox B){
Boolean a = (A.extremites.get("HautGauche").getX() > B.extremites.get("HautDroite").getX()); // A est à droite de B
Boolean b = (A.extremites.get("HautDroite").getX() < B.extremites.get("HautGauche").getX()); // A est à gauche de B
Boolean c = (A.extremites.get("HautGauche").getZ() > B.extremites.get("BasGauche").getZ()); // A est en dessous de B
Boolean d = (A.extremites.get("BasGauche").getZ() < B.extremites.get("HautGauche").getZ()); // A est au dessus de B
return (!a && !b && !c && !d);
Boolean a = !(A.extremites.get("HautGauche").getX() > B.extremites.get("HautDroite").getX()); // A est à droite de B
Boolean b = !(A.extremites.get("HautDroite").getX() < B.extremites.get("HautGauche").getX()); // A est à gauche de B
Boolean c = !(A.extremites.get("HautGauche").getZ() > B.extremites.get("BasGauche").getZ()); // A est en dessous de B
Boolean d = !(A.extremites.get("BasGauche").getZ() < B.extremites.get("HautGauche").getZ()); // A est au dessus de B
return a && b && c && d;
}
public HashMap<String, Coordonnees> getExtremites() {
return extremites;
......
package map;
import java.util.HashMap;
import java.util.List;
import entity.Entity;
import environnement.HitBox;
import jeu.Jeu;
......@@ -44,6 +43,7 @@ public class Obstacle {
public static Boolean collisionBas(Entity charac){
HashMap<String,Boolean> collisionMap = HitBox.collisionMap(charac.getHitBox(), charac.getObstacleBeneath().getHitbox());
if (charac.getObstacleBeneath() != Jeu.getSol()){
System.out.println("jcxvsfdkjjhsdkghjsdkj");
if (collisionMap.get("collision_droite") && collisionMap.get("collision_gauche") && !collisionMap.get("collision_bas")) {
return true;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment