diff --git a/pom.xml b/pom.xml
index e1fe2ca..69a68b2 100644
--- a/pom.xml
+++ b/pom.xml
@@ -31,6 +31,13 @@
1.12.1
natives-desktop
+
+
+ org.apache.logging.log4j
+ log4j-core
+ 2.25.3
+ compile
+
\ No newline at end of file
diff --git a/src/main/java/bzh/risotto/GameMap.java b/src/main/java/bzh/risotto/GameMap.java
index 1bf15ec..f1a1fc6 100644
--- a/src/main/java/bzh/risotto/GameMap.java
+++ b/src/main/java/bzh/risotto/GameMap.java
@@ -18,7 +18,7 @@ public class GameMap {
public GameMap() {
- this.tileSet = new TileSet("tileset.png", new Vector2(16,16), new Vector2(5,5));
+ this.tileSet = new TileSet("tileset.png", new Vector2(16,16), new Vector2(6,6));
List> map = loadMap();
this.tileMap = new TileMap(this.tileSet, map);
}
@@ -31,7 +31,9 @@ public class GameMap {
for (int i = 0; i < 10; i++) {
row = new ArrayList<>();
for (int j = 0; j < 10; j++) {
- int tileId = (int) (Math.random()*3);
+
+ int tileId = (i+j)%3;
+
row.add(tileId);
}
res.add(row);
diff --git a/src/main/java/bzh/risotto/Minesweeper.java b/src/main/java/bzh/risotto/Minesweeper.java
index 649bd05..3d54393 100644
--- a/src/main/java/bzh/risotto/Minesweeper.java
+++ b/src/main/java/bzh/risotto/Minesweeper.java
@@ -15,7 +15,7 @@ public class Minesweeper implements ApplicationListener {
@Override
public void create() {
- viewport = new FitViewport(100,150);
+ viewport = new FitViewport(30,30);
spriteBatch = new SpriteBatch();
gameMap = new GameMap();
diff --git a/src/main/java/bzh/risotto/tilemap/TileMap.java b/src/main/java/bzh/risotto/tilemap/TileMap.java
index a2a72b1..4ba758b 100644
--- a/src/main/java/bzh/risotto/tilemap/TileMap.java
+++ b/src/main/java/bzh/risotto/tilemap/TileMap.java
@@ -2,6 +2,8 @@ package bzh.risotto.tilemap;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.math.Vector2;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
import java.util.ArrayList;
import java.util.List;
@@ -20,6 +22,8 @@ public class TileMap {
/** 2D list that store the map tiles */
private final List> tileList;
+ private static final Logger logger = LogManager.getLogger();
+
/**
* Load and create the tileMap from a 2D integer list
*
@@ -47,6 +51,9 @@ public class TileMap {
tmpList = new ArrayList<>();
for (int i = 0; i < this.map.get(j).size(); i++) {
tileId = this.map.get(j).get(i);
+
+ logger.debug("Tile id: " + tileId);
+
tile = this.tileSet.getTile(tileId);
tmpList.add(tile);
}
@@ -67,6 +74,7 @@ public class TileMap {
for (int j = 0; j < tileList.size(); j++) {
for (int i = 0; i < tileList.get(j).size(); i++) {
tile = tileList.get(j).get(i);
+
pos = new Vector2(i*tileSize.x,j*tileSize.y);
tile.render(spriteBatch, pos);
}
diff --git a/src/main/java/bzh/risotto/tilemap/TileSet.java b/src/main/java/bzh/risotto/tilemap/TileSet.java
index e3ac267..5d262be 100644
--- a/src/main/java/bzh/risotto/tilemap/TileSet.java
+++ b/src/main/java/bzh/risotto/tilemap/TileSet.java
@@ -3,6 +3,8 @@ package bzh.risotto.tilemap;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.math.Vector2;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
import java.util.ArrayList;
@@ -23,6 +25,8 @@ public class TileSet {
/** number of tiles in the tileset */
private final Vector2 tilesetSize;
+ private Logger logger = LogManager.getLogger();
+
/**
* Constructor of the class
* Loads an array of tile from the tileset
@@ -52,16 +56,23 @@ public class TileSet {
for (int i = 0; i < this.tilesetSize.y; i++) {
for (int j = 0; j < this.tilesetSize.x; j++) {
+ Vector2 p = new Vector2(80,80);
+
tile = new Tile(
+
new TextureRegion(
this.tilesTexture,
- j*tileSize.x,
- i*tilesetSize.y,
- tileSize.x,
- tileSize.y
+ j*(int) tileSize.x,
+ i* (int) tileSize.y,
+ (int) tileSize.x,
+ (int) tileSize.y
)
);
+ logger.debug("------");
+ logger.debug("x:" + j*tileSize.x);
+ logger.debug("y:" + i*tileSize.y);
+ logger.debug(tileSize);
tileArray.add(tile);
}
}
diff --git a/src/main/resources/log4j2.xml b/src/main/resources/log4j2.xml
new file mode 100644
index 0000000..0bd7ed7
--- /dev/null
+++ b/src/main/resources/log4j2.xml
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file