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

Nouvelle map avec collisions, doit régler couleurs et hitbox

parent 70efa298
No related branches found
No related tags found
No related merge requests found
...@@ -32,8 +32,8 @@ public class Jeu implements Game{ ...@@ -32,8 +32,8 @@ public class Jeu implements Game{
//Coordonees de debut du personnage //Coordonees de debut du personnage
static final double zdebut = 0; static final double zdebut = 300;
static final double xdebut = 200; static final double xdebut = 700;
//perso //perso
static Character gameCharacter; static Character gameCharacter;
...@@ -69,7 +69,7 @@ public class Jeu implements Game{ ...@@ -69,7 +69,7 @@ public class Jeu implements Game{
private static List<Coffre> coffreTable = new ArrayList<>(); private static List<Coffre> coffreTable = new ArrayList<>();
public final static int TILES_DEFAULT_SIZE=32; public final static int TILES_DEFAULT_SIZE=32;
public final static float SCALE=1.75f; public final static float SCALE=1.25f;
public final static int TILES_IN_WIDTH = 60; public final static int TILES_IN_WIDTH = 60;
public final static int TILES_IN_HEIGHT = 20; public final static int TILES_IN_HEIGHT = 20;
public final static int TILES_SIZE = (int) (TILES_DEFAULT_SIZE*SCALE); public final static int TILES_SIZE = (int) (TILES_DEFAULT_SIZE*SCALE);
......
...@@ -24,8 +24,8 @@ public class Painter implements GamePainter{ ...@@ -24,8 +24,8 @@ public class Painter implements GamePainter{
//protected static final int WIDTH = TILES_SIZE*TILES_IN_WIDTH; //protected static final int WIDTH = TILES_SIZE*TILES_IN_WIDTH;
//protected static final int HEIGHT = TILES_SIZE*TILES_IN_HEIGHT; //protected static final int HEIGHT = TILES_SIZE*TILES_IN_HEIGHT;
protected static final int WIDTH =1000; protected static final int WIDTH =1500;
protected static final int HEIGHT=700; protected static final int HEIGHT=1000;
private LevelManager levelManager; private LevelManager levelManager;
public static Obstacle test = new Obstacle(new HitBox(new Coordonnees(300,550),32,128)); public static Obstacle test = new Obstacle(new HitBox(new Coordonnees(300,550),32,128));
......
...@@ -13,8 +13,8 @@ public class LoadSave { ...@@ -13,8 +13,8 @@ public class LoadSave {
public static final String LEVEL_SPRITES = "Obstacles/Map_level_one.png"; public static final String LEVEL_SPRITES = "Obstacles/Map_sprites.png";
public static final String LEVEL_ONE = "Obstacles/level_one2.png"; public static final String LEVEL_ONE = "Obstacles/level_one.png";
public static BufferedImage GetSpriteAtlas(String fileName) { public static BufferedImage GetSpriteAtlas(String fileName) {
BufferedImage img = null; BufferedImage img = null;
...@@ -42,8 +42,8 @@ public class LoadSave { ...@@ -42,8 +42,8 @@ public class LoadSave {
for (int i = 0; i < img.getWidth(); i++) { for (int i = 0; i < img.getWidth(); i++) {
Color color = new Color(img.getRGB(i, j)); Color color = new Color(img.getRGB(i, j));
int value = color.getRed(); int value = color.getRed();
if (value >= 18) if (value >= 27)
value = 0; value = 34;
lvlData[j][i] = value; lvlData[j][i] = value;
} }
return lvlData; return lvlData;
......
...@@ -25,12 +25,21 @@ public class LevelManager { ...@@ -25,12 +25,21 @@ public class LevelManager {
private void importOutsideSprites() { private void importOutsideSprites() {
BufferedImage img = LoadSave.GetSpriteAtlas(LoadSave.LEVEL_SPRITES); BufferedImage img = LoadSave.GetSpriteAtlas(LoadSave.LEVEL_SPRITES);
levelSprite = new BufferedImage[18]; levelSprite = new BufferedImage[7];
for (int j = 0; j < 2; j++)
//Pour les sprites de chaque bloc
levelSprite[0] = img.getSubimage(0, 0, 32, 192);
levelSprite[1] = img.getSubimage( 32, 0, 32, 96);
levelSprite[2] = img.getSubimage(2 * 32, 0, 32, 64);
levelSprite[3] = img.getSubimage(3 * 32, 0, 64, 32);
levelSprite[4] = img.getSubimage(5 * 32, 0, 96, 32);
levelSprite[5] = img.getSubimage(3 * 32, 32, 32, 32);
levelSprite[6] = img.getSubimage(32, 3 * 32, 224, 32);
/*for (int j = 0; j < 2; j++)
for (int i = 0; i < 9; i++) { for (int i = 0; i < 9; i++) {
int index = j * 9 + i; int index = j * 9 + i;
levelSprite[index] = img.getSubimage(i * 32, j * 32, 32, 32); levelSprite[index] = img.getSubimage(i * 32, j * 32, 32, 32);
} }*/
} }
public List<Obstacle> generateObstacleTable() { public List<Obstacle> generateObstacleTable() {
...@@ -39,10 +48,37 @@ public class LevelManager { ...@@ -39,10 +48,37 @@ public class LevelManager {
for (int i = 0; i < Jeu.TILES_IN_WIDTH; i++) { for (int i = 0; i < Jeu.TILES_IN_WIDTH; i++) {
int index = levelOne.getSpriteIndex(i, j); int index = levelOne.getSpriteIndex(i, j);
//g.drawImage(levelSprite[index], Jeu.TILES_SIZE * i, Jeu.TILES_SIZE * j, Jeu.TILES_SIZE, Jeu.TILES_SIZE, null); //g.drawImage(levelSprite[index], Jeu.TILES_SIZE * i, Jeu.TILES_SIZE * j, Jeu.TILES_SIZE, Jeu.TILES_SIZE, null);
if (index<=14) {
liste.add(new Obstacle(new HitBox(new Coordonnees(Jeu.TILES_SIZE * i, Jeu.TILES_SIZE * j-600), Jeu.TILES_SIZE, Jeu.TILES_SIZE))); //Index selon la couleur associée au bloc
System.out.println(liste.size()); 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)));
}
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)));
}
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)));
}
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)));
}
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)));
}
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)));
}
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)));
} }
System.out.println(liste.size());
} }
return liste; return liste;
} }
......
MAVENProject/src/main/resources/Obstacles/Map_sprites.png

35.4 KiB

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

1.14 KiB

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