Skip to content
Snippets Groups Projects
Commit 68019a10 authored by Louis MALTERRE's avatar Louis MALTERRE
Browse files

debut implementation de l attaque sur le perso LM

parent 146a72ed
No related branches found
No related tags found
No related merge requests found
...@@ -18,4 +18,10 @@ public class Attack { ...@@ -18,4 +18,10 @@ public class Attack {
public void dealDamage(Entity entity){ public void dealDamage(Entity entity){
entity.setNbLifePoints(Math.max(entity.getNbLifePoints()-damage, 0)); entity.setNbLifePoints(Math.max(entity.getNbLifePoints()-damage, 0));
} }
public HitBox getHitBox() {
return hitBox;
}
} }
...@@ -136,8 +136,10 @@ public class Character extends Entity{ ...@@ -136,8 +136,10 @@ public class Character extends Entity{
@Override @Override
public void attaque(){ public void attaque(){
Coordonnees attackCenter = new Coordonnees(coord.getX() + direction*entityWIDTH/2, coord.getZ());
Attack characterAttack = new Attack(attackStat, attackCenter, new HitBox(attackCenter,entityHEIGHT,entityWIDTH));
for (Monster monster : Jeu.getMonsterList()){ for (Monster monster : Jeu.getMonsterList()){
if (HitBox.collision(this.hitBox, monster.getHitBox()) && tableCommande.get("CommandAttack") == 1){ if (HitBox.collision(characterAttack.getHitBox(), monster.getHitBox())){
//le Math.max est la juste pour que la vie du perso ne tombe pas en-dessous de zero //le Math.max est la juste pour que la vie du perso ne tombe pas en-dessous de zero
monster.setNbLifePoints(Math.max(monster.getNbLifePoints()-attackStat,0)); monster.setNbLifePoints(Math.max(monster.getNbLifePoints()-attackStat,0));
} }
...@@ -172,10 +174,10 @@ public class Character extends Entity{ ...@@ -172,10 +174,10 @@ public class Character extends Entity{
public void evolveCharacter(){ public void evolveCharacter(){
getGameCommand(); getGameCommand();
deplacements(); deplacements();
attaque();
collisionGestion(); collisionGestion();
updateVoisinage(); updateVoisinage();
this.setHitBox(new HitBox(this.getCoord(),entityHEIGHT,entityWIDTH)); // mise à jour moins crade pour l'instant this.setHitBox(new HitBox(this.getCoord(),entityHEIGHT,entityWIDTH)); // mise à jour moins crade pour l'instant
if (tableCommande.get("CommandAttack") == 1) attaque();
resetCommand(); resetCommand();
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment