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

Suppression carrés voisinage

parent 828ee5cc
Branches
No related tags found
No related merge requests found
...@@ -57,7 +57,7 @@ public class Painter implements GamePainter{ ...@@ -57,7 +57,7 @@ public class Painter implements GamePainter{
private void drawCharacter(Graphics2D crayon,Image imageCharac){ private void drawCharacter(Graphics2D crayon,Image imageCharac){
if (gameCharacter.getNbFramesInvincible() > 0)crayon.setColor(Color.black); if (gameCharacter.getNbFramesInvincible() > 0)crayon.setColor(Color.black);
crayon.fillRect(WIDTH/2-(int) gameCharacter.getEntityWIDTH()/2,HEIGHT/2-(int) gameCharacter.getEntityHEIGHT()/2+decalage, (int) gameCharacter.getEntityWIDTH(),(int) gameCharacter.getEntityHEIGHT()); crayon.fillRect(WIDTH/2-(int) gameCharacter.getEntityWIDTH()/2,HEIGHT/2-(int) gameCharacter.getEntityHEIGHT()/2+decalage, (int) gameCharacter.getEntityWIDTH(),(int) gameCharacter.getEntityHEIGHT());
crayon.drawRect(WIDTH/2-500,WIDTH/2-500, 1000,1000); //crayon.drawRect(WIDTH/2-500,WIDTH/2-500, 1000,1000);
if (gameCharacter.getDirection() == 1){ if (gameCharacter.getDirection() == 1){
crayon.drawImage(imageCharac, WIDTH/2- (int) gameCharacter.getEntityWIDTH()/2-10, HEIGHT/2 - (int) gameCharacter.getEntityHEIGHT()/2-3+decalage, null, null); crayon.drawImage(imageCharac, WIDTH/2- (int) gameCharacter.getEntityWIDTH()/2-10, HEIGHT/2 - (int) gameCharacter.getEntityHEIGHT()/2-3+decalage, null, null);
} }
...@@ -96,13 +96,20 @@ public class Painter implements GamePainter{ ...@@ -96,13 +96,20 @@ public class Painter implements GamePainter{
Coordonnees bd = extremites.get("BasDroite"); Coordonnees bd = extremites.get("BasDroite");
Coordonnees hg = extremites.get("HautGauche"); Coordonnees hg = extremites.get("HautGauche");
Coordonnees bg = extremites.get("BasGauche"); Coordonnees bg = extremites.get("BasGauche");
if (HitBox.collision(gameCharacter.getVoisinage(), obstacle.getHitbox()))crayon.setColor(Color.green); //if (HitBox.collision(gameCharacter.getVoisinage(), obstacle.getHitbox()))crayon.setColor(Color.green);
crayon.drawLine((int)hd.getX() - xCam,(int)hd.getZ() - zCam,(int)bd.getX() - xCam,(int)bd.getZ() - zCam); crayon.drawLine((int)hd.getX() - xCam,(int)hd.getZ() - zCam,(int)bd.getX() - xCam,(int)bd.getZ() - zCam);
crayon.drawLine((int)bd.getX() - xCam,(int)bd.getZ() - zCam,(int)bg.getX() - xCam,(int)bg.getZ() - zCam); crayon.drawLine((int)bd.getX() - xCam,(int)bd.getZ() - zCam,(int)bg.getX() - xCam,(int)bg.getZ() - zCam);
crayon.drawLine((int)bg.getX() - xCam,(int)bg.getZ() - zCam,(int)hg.getX() - xCam,(int)hg.getZ() - zCam); crayon.drawLine((int)bg.getX() - xCam,(int)bg.getZ() - zCam,(int)hg.getX() - xCam,(int)hg.getZ() - zCam);
crayon.drawLine((int)hg.getX() - xCam,(int)hg.getZ() - zCam,(int)hd.getX() - xCam,(int)hd.getZ() - zCam); crayon.drawLine((int)hg.getX() - xCam,(int)hg.getZ() - zCam,(int)hd.getX() - xCam,(int)hd.getZ() - zCam);
} }
private void drawObstacleBis(Graphics2D crayon, Obstacle obstacle, String nom){
ObstacleLoader loader = new ObstacleLoader(obstacle,nom);
HitBox hitBox = loader.getObstacle().getHitbox();
int z = (int) hitBox.getCentre().getZ();
int x = (int) hitBox.getCentre().getX();
crayon.drawImage(loader.getImageObstacle(), x - (int) hitBox.getWidth()/2 -xCam,z - (int) hitBox.getHeight()/2 -zCam,null,null);
}
private void drawCoffre(Graphics2D crayon, Coffre coffre){ private void drawCoffre(Graphics2D crayon, Coffre coffre){
HashMap<String, Coordonnees> extremites = coffre.getHitbox().getExtremites(); HashMap<String, Coordonnees> extremites = coffre.getHitbox().getExtremites();
Coordonnees hd = extremites.get("HautDroite"); Coordonnees hd = extremites.get("HautDroite");
...@@ -165,7 +172,7 @@ public class Painter implements GamePainter{ ...@@ -165,7 +172,7 @@ public class Painter implements GamePainter{
x = (int)monster.getCoord().getX(); x = (int)monster.getCoord().getX();
z = (int)monster.getCoord().getZ(); z = (int)monster.getCoord().getZ();
crayon.drawRect(x-300 - xCam, z-300 - zCam, 600, 600); //crayon.drawRect(x-300 - xCam, z-300 - zCam, 600, 600);
if (HitBox.collision(gameCharacter.getHitBox(),monster.getHitBox()))crayon.setColor(Color.red); if (HitBox.collision(gameCharacter.getHitBox(),monster.getHitBox()))crayon.setColor(Color.red);
if (monster.getNbFramesInvincible() > 0)crayon.setColor(Color.black); if (monster.getNbFramesInvincible() > 0)crayon.setColor(Color.black);
crayon.fillRect(x-(int)monster.getEntityWIDTH()/2 - xCam, z-(int)monster.getEntityHEIGHT()/2 - zCam, (int)monster.getEntityWIDTH(), (int)monster.getEntityHEIGHT()); crayon.fillRect(x-(int)monster.getEntityWIDTH()/2 - xCam, z-(int)monster.getEntityHEIGHT()/2 - zCam, (int)monster.getEntityWIDTH(), (int)monster.getEntityHEIGHT());
......
...@@ -3,6 +3,7 @@ import map.Obstacle; ...@@ -3,6 +3,7 @@ import map.Obstacle;
import javax.swing.*; import javax.swing.*;
import java.awt.*; import java.awt.*;
import java.awt.image.BufferedImage;
import java.net.URL; import java.net.URL;
public class ObstacleLoader { public class ObstacleLoader {
...@@ -26,4 +27,9 @@ public class ObstacleLoader { ...@@ -26,4 +27,9 @@ public class ObstacleLoader {
obstacle = obs; obstacle = obs;
imageObstacle = new ImageIcon(path).getImage(); imageObstacle = new ImageIcon(path).getImage();
} }
public ObstacleLoader(Obstacle obs, BufferedImage image){
obstacle = obs;
imageObstacle = image;
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment