Skip to content
Snippets Groups Projects
Commit 0fff33bf authored by BRUGNEAUX Louis's avatar BRUGNEAUX Louis
Browse files

Nouvelle map avec obstacles bien créés mais bug avec les monstres

parent 29bc2b78
Branches
No related tags found
No related merge requests found
......@@ -9,6 +9,7 @@ import jeu.Jeu;
import map.Obstacle;
import static jeu.Jeu.getGameCharacter;
import static jeu.Jeu.getObstacleTable;
import java.util.ArrayList;
import java.util.HashMap;
......@@ -51,7 +52,7 @@ public class Monster extends Entity{
public void collisionGestion(){
//recupere la liste des obstacles dans le voisinage
List<Obstacle> listeObstaclesInVoisinage = obstacleInVoisinage();
List<Obstacle> listeObstaclesInVoisinage = getObstacleTable();
//stocke l'obstacle avec lequel il y a eu collision
HashMap<Obstacle,PositionCollision> collisionsPresentes = new HashMap<Obstacle,PositionCollision>();
......@@ -62,7 +63,7 @@ public class Monster extends Entity{
//on set alpha a 0 (on le suppose dans les airs)
alpha = 0;
obstacleBeneath = Jeu.getSol();
//on parcourt pour tester si il est sur un block
for (int i=0;i<collisionsPresentes.size();i++){
//si on trouve on sort de la boucle (pas besoin d'aller plus loin)
......@@ -126,7 +127,7 @@ public class Monster extends Entity{
deplacements();
collisionGestion(); // ca merde
attaque();
updateVoisinage();
//updateVoisinage();
this.setHitBox(new HitBox(this.getCoord(),entityHEIGHT,entityWIDTH));
updateNbFrameInvincible();
......
......@@ -61,7 +61,7 @@ public class Jeu implements Game{
private boolean characterAttacking = false; //boolean necessaire pour rendre l'animation d'attaque prioritaire
public static Obstacle sol = new Obstacle(new HitBox(new Coordonnees(200,850),56,1000000));
public static Obstacle sol = new Obstacle(new HitBox(new Coordonnees(200,1092),56,1000000));
public static List<Obstacle> obstacleTable = new ArrayList<>();
private static List<Monster> monsterList = new ArrayList<>();
......@@ -69,7 +69,7 @@ public class Jeu implements Game{
private static List<Coffre> coffreTable = new ArrayList<>();
public final static int TILES_DEFAULT_SIZE=32;
public final static float SCALE=1.25f;
public final static float SCALE=1.75f;
public final static int TILES_IN_WIDTH = 60;
public final static int TILES_IN_HEIGHT = 20;
public final static int TILES_SIZE = (int) (TILES_DEFAULT_SIZE*SCALE);
......@@ -89,7 +89,8 @@ public class Jeu implements Game{
/*A = new ArrayList<Double>();
n = 0;*/
LevelManager levelManager = new LevelManager();
levelManager = new LevelManager();
levelManager.generateObstacleTable();
......@@ -114,10 +115,12 @@ public class Jeu implements Game{
//faut supp la pour table obstacles
obstacleTable= levelManager.generateObstacleTable();
obstacleTable.add(sol);
obstacleTable= levelManager.getListeObstacle();
obstacleTable.add(sol);
monsterList= levelManager.getListeMonster();
/*obstacleTable.add(new Obstacle(new HitBox(new Coordonnees(300,550),32,128)));
obstacleTable.add(new Obstacle(new HitBox(new Coordonnees(800, 625),150,50)));
......
......@@ -14,7 +14,7 @@ public class LoadSave {
public static final String LEVEL_SPRITES = "Obstacles/Map_sprites.png";
public static final String LEVEL_ONE = "Obstacles/level_one.png";
public static final String LEVEL_ONE = "Obstacles/level_one_monster.png";
public static BufferedImage GetSpriteAtlas(String fileName) {
BufferedImage img = null;
......@@ -58,6 +58,12 @@ public class LoadSave {
value = 12;
if (131<=value && value <= 150)
value = 11;
//MOnstres à pied
if (151<=value && value <= 170)
value = 13;
//Bat
if (171<=value && value <= 190)
value = 14;
lvlData[j][i] = value;
}
return lvlData;
......
......@@ -5,6 +5,8 @@ import java.awt.image.BufferedImage;
import java.util.ArrayList;
import java.util.List;
import entity.Bat;
import entity.Monster;
import environnement.Coordonnees;
import environnement.HitBox;
import jeu.Jeu;
......@@ -17,6 +19,8 @@ public class LevelManager {
private Painter painter;
private BufferedImage[] levelSprite;
private Level levelOne;
private List<Obstacle> listeObstacle= new ArrayList<>();
private List<Monster> listeMonster= new ArrayList<>();
public LevelManager() {
importOutsideSprites();
......@@ -42,8 +46,8 @@ public class LevelManager {
}*/
}
public List<Obstacle> generateObstacleTable() {
List<Obstacle> liste = new ArrayList<>();
public void generateObstacleTable() {
for (int j = 0; j < Jeu.TILES_IN_HEIGHT; j++)
for (int i = 0; i < Jeu.TILES_IN_WIDTH; i++) {
int index = levelOne.getSpriteIndex(i, j);
......@@ -51,35 +55,53 @@ public class LevelManager {
//Index selon la couleur associée au bloc
if (index==0) {
liste.add(new Obstacle(new HitBox(new Coordonnees(Jeu.TILES_SIZE * i, Jeu.TILES_SIZE * j), 6*Jeu.TILES_SIZE, 1*Jeu.TILES_SIZE)));
listeObstacle.add(new Obstacle(new HitBox(new Coordonnees(Jeu.TILES_SIZE * i+Jeu.TILES_SIZE/2, Jeu.TILES_SIZE * j-6*Jeu.TILES_SIZE/2), 6*Jeu.TILES_SIZE, 1*Jeu.TILES_SIZE)));
}
if (index==1) {
liste.add(new Obstacle(new HitBox(new Coordonnees(Jeu.TILES_SIZE * i, Jeu.TILES_SIZE * j), 3*Jeu.TILES_SIZE, 1*Jeu.TILES_SIZE)));
listeObstacle.add(new Obstacle(new HitBox(new Coordonnees(Jeu.TILES_SIZE * i+Jeu.TILES_SIZE/2, Jeu.TILES_SIZE * j-3*Jeu.TILES_SIZE/2), 3*Jeu.TILES_SIZE, 1*Jeu.TILES_SIZE)));
}
if (index==2) {
liste.add(new Obstacle(new HitBox(new Coordonnees(Jeu.TILES_SIZE * i, Jeu.TILES_SIZE * j), 2*Jeu.TILES_SIZE, 1*Jeu.TILES_SIZE)));
listeObstacle.add(new Obstacle(new HitBox(new Coordonnees(Jeu.TILES_SIZE * i+Jeu.TILES_SIZE/2, Jeu.TILES_SIZE * j-2*Jeu.TILES_SIZE/2), 2*Jeu.TILES_SIZE, 1*Jeu.TILES_SIZE)));
}
if (index==3) {
liste.add(new Obstacle(new HitBox(new Coordonnees(Jeu.TILES_SIZE * i, Jeu.TILES_SIZE * j), 1*Jeu.TILES_SIZE, 2*Jeu.TILES_SIZE)));
listeObstacle.add(new Obstacle(new HitBox(new Coordonnees(Jeu.TILES_SIZE * i+2*Jeu.TILES_SIZE/2, Jeu.TILES_SIZE * j-Jeu.TILES_SIZE/2), 1*Jeu.TILES_SIZE, 2*Jeu.TILES_SIZE)));
}
if (index==5) {
liste.add(new Obstacle(new HitBox(new Coordonnees(Jeu.TILES_SIZE * i, Jeu.TILES_SIZE * j), 1*Jeu.TILES_SIZE, 3*Jeu.TILES_SIZE)));
listeObstacle.add(new Obstacle(new HitBox(new Coordonnees(Jeu.TILES_SIZE * i+3*Jeu.TILES_SIZE/2, Jeu.TILES_SIZE * j-Jeu.TILES_SIZE/2), 1*Jeu.TILES_SIZE, 3*Jeu.TILES_SIZE)));
}
//Coffres
if (index==11) {
liste.add(new Obstacle(new HitBox(new Coordonnees(Jeu.TILES_SIZE * i, Jeu.TILES_SIZE * j), Jeu.TILES_SIZE, Jeu.TILES_SIZE)));
listeObstacle.add(new Obstacle(new HitBox(new Coordonnees(Jeu.TILES_SIZE * i+Jeu.TILES_SIZE/2, Jeu.TILES_SIZE * j-Jeu.TILES_SIZE/2), Jeu.TILES_SIZE, Jeu.TILES_SIZE)));
}
if (index==25) {
liste.add(new Obstacle(new HitBox(new Coordonnees(Jeu.TILES_SIZE * i, Jeu.TILES_SIZE * j), 1*Jeu.TILES_SIZE, 7*Jeu.TILES_SIZE)));
listeObstacle.add(new Obstacle(new HitBox(new Coordonnees(Jeu.TILES_SIZE * i+7*Jeu.TILES_SIZE/2, Jeu.TILES_SIZE * j-Jeu.TILES_SIZE/2), 1*Jeu.TILES_SIZE, 7*Jeu.TILES_SIZE)));
}
//Monstres à pied
/*if (index==13) {
listeMonster.add(new Monster(new Coordonnees(Jeu.TILES_SIZE * i+30/2, Jeu.TILES_SIZE * j-62/2), 1000, 30, 60, 1,5));
}
//chauve-souris
if (index==14) {
listeMonster.add(new Bat(new Coordonnees(Jeu.TILES_SIZE * i+20/2, Jeu.TILES_SIZE * j-32/2), 1, 3));
}*/
}
return liste;
}
public List<Obstacle> getListeObstacle() {
return listeObstacle;
}
public List<Monster> getListeMonster() {
return listeMonster;
}
public void update() {
......
package start;
import jeu.Painter;
import map.LevelManager;
import spotify.MP3;
import engine.GameEngineGraphical;
......@@ -18,7 +19,7 @@ public class Main {
Jeu game = new Jeu("helpFilePacman.txt");
Painter painter = new Painter();
Controller controller = new Controller();
//pour la musique
MP3 mp3 = new MP3("cyberPacMusic1bon.wav");
......
MAVENProject/src/main/resources/Obstacles/level_one2.png

1.07 KiB

MAVENProject/src/main/resources/Obstacles/level_one_monster.png

916 B

0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment