Skip to content
Snippets Groups Projects
Commit 7f69a108 authored by bruno's avatar bruno
Browse files

Coffre

parent fdcfb2b1
No related branches found
No related tags found
No related merge requests found
......@@ -23,6 +23,7 @@ public class Character extends Entity{
private double vitesseActuZ = 0;
private final double impulsionSaut;
private double masse;
private int clef;
private Map<String,Double> tableCommande; //table des commandes du perso
......@@ -131,6 +132,14 @@ public class Character extends Entity{
}
}
}
public void clef(){
for (Coffre coffre : Jeu.getCoffreTable()){
if (HitBox.collision(this.hitBox, coffre.getHitBox()){
monster.setNbLifePoints(Math.max(monster.getNbLifePoints()-attackStat,0));
}
}
}
public void getGameCommand(){
......
......@@ -16,6 +16,7 @@ import environnement.Coordonnees;
import environnement.HitBox;
import environnement.PositionCollision;
import map.Obstacle;
import map.Coffre;
import loaders.CharacterLoader;
import static environnement.PositionCollision.*;
......@@ -57,6 +58,7 @@ public class Jeu implements Game{
private static List<Obstacle> obstacleTable = new ArrayList<>();
private static List<PositionCollision> obstacleTableCollisionCharac= new ArrayList<>();
private static List<Monster> monsterList = new ArrayList<>();
private static List<Coffre> coffreTable = new ArrayList<>();
......@@ -108,6 +110,7 @@ public class Jeu implements Game{
obstacleTable.add(new Obstacle(new HitBox(new Coordonnees(300,550),32,128)));
obstacleTable.add(new Obstacle(new HitBox(new Coordonnees(800, 625),150,50)));
obstacleTable.add(new Obstacle(new HitBox(new Coordonnees(600, 662.5),75,50)));
coffreTable.add(new Coffre(new HitBox(new Coordonnees(900, 685),30,30)));
obstacleTableCollisionCharac.add(NONE);
obstacleTableCollisionCharac.add(NONE);
......@@ -203,6 +206,9 @@ public class Jeu implements Game{
public static List<Obstacle> getObstacleTable() {
return obstacleTable;
}
public static List<Coffre> getCoffreTable() {
return coffreTable;
}
public static List<PositionCollision> getObstacleTableCollisionCharac() {
return obstacleTableCollisionCharac;
}
......
......@@ -6,6 +6,8 @@ import environnement.Coordonnees;
import environnement.HitBox;
import loaders.ObstacleLoader;
import map.Obstacle;
import loaders.CoffreLoader;
import map.Coffre;
import java.awt.*;
import java.awt.image.BufferedImage;
......@@ -82,6 +84,18 @@ public class Painter implements GamePainter{
crayon.drawLine((int)bg.getX(),(int)bg.getZ(),(int)hg.getX(),(int)hg.getZ());
crayon.drawLine((int)hg.getX(),(int)hg.getZ(),(int)hd.getX(),(int)hd.getZ());
}
private void drawCoffre(Graphics2D crayon, Coffre coffre){
HashMap<String, Coordonnees> extremites = coffre.getHitbox().getExtremites();
Coordonnees hd = extremites.get("HautDroite");
Coordonnees bd = extremites.get("BasDroite");
Coordonnees hg = extremites.get("HautGauche");
Coordonnees bg = extremites.get("BasGauche");
crayon.drawLine((int)hd.getX(),(int)hd.getZ(),(int)bd.getX(),(int)bd.getZ());
crayon.drawLine((int)bd.getX(),(int)bd.getZ(),(int)bg.getX(),(int)bg.getZ());
crayon.drawLine((int)bg.getX(),(int)bg.getZ(),(int)hg.getX(),(int)hg.getZ());
crayon.drawLine((int)hg.getX(),(int)hg.getZ(),(int)hd.getX(),(int)hd.getZ());
}
private void drawSol(Graphics2D crayon){
......@@ -103,6 +117,15 @@ public class Painter implements GamePainter{
}
drawObstacle(crayon,obs);
}
for (Coffre obs : Jeu.getCoffreTable()){
if (!collision(gameCharacter.getHitBox(), obs.getHitbox())){
crayon.setColor(Color.blue);
}
else {
crayon.setColor(Color.red);
}
drawCoffre(crayon,obs);
}
}
private void drawObstacleBis(Graphics2D crayon, Obstacle obstacle, String nom){
......@@ -112,6 +135,14 @@ public class Painter implements GamePainter{
int x = (int) hitBox.getCentre().getX();
crayon.drawImage(loader.getImageObstacle(), x - (int) hitBox.getWidth()/2,z - (int) hitBox.getHeight()/2,null,null);
}
private void drawCoffreBis(Graphics2D crayon, Coffre coffre, String nom){
CoffreLoader loader = new CoffreLoader(coffre,nom);
HitBox hitBox = loader.getCoffre().getHitbox();
int z = (int) hitBox.getCentre().getZ();
int x = (int) hitBox.getCentre().getX();
crayon.drawImage(loader.getImageCoffre(), x - (int) hitBox.getWidth()/2,z - (int) hitBox.getHeight()/2,null,null);
}
private void drawMonsters(Graphics2D crayon){
int x;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment