diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..fbb16c8
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,4 @@
+/.gradle/
+/.idea/
+/build/
+/out/
diff --git a/.gradle/7.3.3/checksums/checksums.lock b/.gradle/7.3.3/checksums/checksums.lock
deleted file mode 100644
index 58fd0e2..0000000
Binary files a/.gradle/7.3.3/checksums/checksums.lock and /dev/null differ
diff --git a/.gradle/7.3.3/fileHashes/fileHashes.lock b/.gradle/7.3.3/fileHashes/fileHashes.lock
deleted file mode 100644
index 6a2372b..0000000
Binary files a/.gradle/7.3.3/fileHashes/fileHashes.lock and /dev/null differ
diff --git a/.idea/.gitignore b/.idea/.gitignore
deleted file mode 100644
index 13566b8..0000000
--- a/.idea/.gitignore
+++ /dev/null
@@ -1,8 +0,0 @@
-# Default ignored files
-/shelf/
-/workspace.xml
-# Editor-based HTTP Client requests
-/httpRequests/
-# Datasource local storage ignored files
-/dataSources/
-/dataSources.local.xml
diff --git a/.idea/.name b/.idea/.name
deleted file mode 100644
index 941e2fa..0000000
--- a/.idea/.name
+++ /dev/null
@@ -1 +0,0 @@
-terraria
\ No newline at end of file
diff --git a/.idea/compiler.xml b/.idea/compiler.xml
deleted file mode 100644
index fb7f4a8..0000000
--- a/.idea/compiler.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/discord.xml b/.idea/discord.xml
deleted file mode 100644
index 30bab2a..0000000
--- a/.idea/discord.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/gradle.xml b/.idea/gradle.xml
deleted file mode 100644
index 611e7c8..0000000
--- a/.idea/gradle.xml
+++ /dev/null
@@ -1,17 +0,0 @@
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml
deleted file mode 100644
index fdc392f..0000000
--- a/.idea/jarRepositories.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
deleted file mode 100644
index b9d0bed..0000000
--- a/.idea/misc.xml
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
deleted file mode 100644
index 94a25f7..0000000
--- a/.idea/vcs.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/build.gradle b/build.gradle
index 2db4289..564b133 100644
--- a/build.gradle
+++ b/build.gradle
@@ -13,7 +13,7 @@ repositories {
}
ext {
- junitVersion = '5.8.1'
+ junitVersion = '5.8.2'
}
sourceCompatibility = '11'
@@ -25,7 +25,7 @@ tasks.withType(JavaCompile) {
application {
mainModule = 'fr.sae.terraria'
- mainClass = 'fr.sae.terraria.HelloApplication'
+ mainClass = 'fr.sae.terraria.Terraria'
}
javafx {
@@ -34,9 +34,10 @@ javafx {
}
dependencies {
-
testImplementation("org.junit.jupiter:junit-jupiter-api:${junitVersion}")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:${junitVersion}")
+
+ implementation group: 'com.google.code.gson', name: 'gson', version: '2.8.7'
}
test {
diff --git a/src/main/java/fr/sae/terraria/Controller.java b/src/main/java/fr/sae/terraria/Controller.java
deleted file mode 100644
index e656a21..0000000
--- a/src/main/java/fr/sae/terraria/Controller.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package fr.sae.terraria;
-
-import javafx.fxml.FXML;
-import javafx.scene.control.Label;
-
-
-public class Controller
-{
- @FXML
- private Label welcomeText;
-
- @FXML
- protected void onHelloButtonClick() {
- welcomeText.setText("Welcome to JavaFX Application!");
- }
-}
\ No newline at end of file
diff --git a/src/main/java/fr/sae/terraria/Environment.java b/src/main/java/fr/sae/terraria/Environment.java
deleted file mode 100644
index b66259c..0000000
--- a/src/main/java/fr/sae/terraria/Environment.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package fr.sae.terraria;
-
-
-public class Environment
-{
-
-}
diff --git a/src/main/java/fr/sae/terraria/Terraria.java b/src/main/java/fr/sae/terraria/Terraria.java
index 2f8572a..bbdc080 100644
--- a/src/main/java/fr/sae/terraria/Terraria.java
+++ b/src/main/java/fr/sae/terraria/Terraria.java
@@ -1,31 +1,45 @@
package fr.sae.terraria;
+import fr.sae.terraria.controller.Controller;
+import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.stage.Stage;
+import java.io.File;
import java.io.IOException;
+import java.net.URL;
-public class Terraria extends javafx.application.Application
+
+public class Terraria extends Application
{
- private String titleWindow = "Terraria-Like!";
+ // TODO: effet de profondeur dans la terre
+ private String titleWindow = "Terraria-Like";
private int widthWindow = 1280;
private int heightWindow = 720;
- @Override
+ public static void main(String[] args) { launch(); }
+
public void start(Stage stage) throws IOException
{
- FXMLLoader fxmlLoader = new FXMLLoader(Terraria.class.getResource("hello-view.fxml"));
+ /* TODO: Commencer par le menu */
+
+ URL pathFxml = Terraria.class.getResource("vue/game.fxml");
+ if (pathFxml == null)
+ pathFxml = new File("src/main/resources/fr/sae/terraria/vue/game.fxml").toURI().toURL();
+
+ FXMLLoader fxmlLoader = new FXMLLoader(pathFxml);
+ Controller ctrl = new Controller(stage);
+ fxmlLoader.setController(ctrl);
Scene scene = new Scene(fxmlLoader.load(), this.widthWindow, this.heightWindow);
-
+
stage.setTitle(this.titleWindow);
+ stage.setResizable(false);
stage.setScene(scene);
- stage.show();
- }
+ stage.sizeToScene();
- public static void main(String[] args) {
- launch();
+ stage.show();
}
}
\ No newline at end of file
diff --git a/src/main/java/fr/sae/terraria/controller/Controller.java b/src/main/java/fr/sae/terraria/controller/Controller.java
new file mode 100644
index 0000000..e75cc2b
--- /dev/null
+++ b/src/main/java/fr/sae/terraria/controller/Controller.java
@@ -0,0 +1,162 @@
+package fr.sae.terraria.controller;
+
+import fr.sae.terraria.modele.blocks.Dirt;
+import fr.sae.terraria.modele.blocks.Stone;
+import fr.sae.terraria.modele.entities.entity.Entity;
+import javafx.beans.property.IntegerProperty;
+import javafx.beans.property.SimpleIntegerProperty;
+import javafx.scene.image.Image;
+import javafx.scene.image.ImageView;
+import javafx.scene.input.KeyEvent;
+import javafx.scene.layout.BorderPane;
+import javafx.scene.layout.HBox;
+import javafx.scene.layout.Pane;
+import javafx.stage.Stage;
+import javafx.fxml.FXML;
+import javafx.fxml.Initializable;
+
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.InputStream;
+
+import java.util.ResourceBundle;
+
+import java.net.URL;
+
+import fr.sae.terraria.Terraria;
+import fr.sae.terraria.modele.Environment;
+import fr.sae.terraria.modele.TileMaps;
+
+
+public class Controller implements Initializable
+{
+ @FXML
+ private BorderPane root;
+ @FXML
+ private HBox title;
+ @FXML
+ private Pane display;
+
+ private IntegerProperty tileWidth = new SimpleIntegerProperty();
+ private IntegerProperty tileHeight = new SimpleIntegerProperty();
+
+ private Environment environment;
+ private TileMaps tiles;
+
+ private int ticks = 0;
+
+
+ public Controller(Stage primaryStage)
+ {
+ environment = new Environment();
+ tiles = new TileMaps();
+
+ primaryStage.addEventFilter(KeyEvent.KEY_PRESSED, key -> {
+ environment.getKeysInput().put(key.getCode(), true);
+ key.consume();
+ });
+
+ primaryStage.addEventFilter(KeyEvent.KEY_RELEASED, key -> {
+ environment.getKeysInput().put(key.getCode(), false);
+ key.consume();
+ });
+
+ primaryStage.heightProperty().addListener((obs, oldV, newV) -> tileHeight.setValue((int) (TileMaps.tileDefaultSize*((newV.intValue()-title.getPrefHeight()) / 256))));
+ primaryStage.widthProperty().addListener((obs, oldV, newV) -> tileWidth.setValue((int) (TileMaps.tileDefaultSize*((newV.intValue() / 465)))));
+ }
+
+ @Override
+ public void initialize(URL location, ResourceBundle resources)
+ {
+ tiles.load("src/main/resources/fr/sae/terraria/maps/map_0.json");
+
+ tileHeight.setValue((int) (TileMaps.tileDefaultSize*((root.getPrefHeight()-title.getPrefHeight()) / 256)));
+ tileWidth.setValue((int) (TileMaps.tileDefaultSize*((root.getPrefWidth() / 465))));
+
+ InputStream floorTopPath = Terraria.class.getResourceAsStream("tiles/floor-top.png");
+ if (floorTopPath == null) try {
+ floorTopPath = new FileInputStream("src/main/resources/fr/sae/terraria/tiles/floor-top.png");
+ } catch (FileNotFoundException e) { throw new RuntimeException(e); }
+ Image floorTopImg = new Image(floorTopPath, tileWidth.get(), tileHeight.get(), false, false);
+
+ InputStream floorLeftPath = Terraria.class.getResourceAsStream("tiles/floor-left.png");
+ if (floorLeftPath == null) try {
+ floorLeftPath = new FileInputStream("src/main/resources/fr/sae/terraria/tiles/floor-left.png");
+ } catch (FileNotFoundException e) { throw new RuntimeException(e); }
+ Image floorLeftImg = new Image(floorLeftPath, tileWidth.get(), tileHeight.get(), false, false);
+
+ InputStream floorRightPath = Terraria.class.getResourceAsStream("tiles/floor-right.png");
+ if (floorRightPath == null) try {
+ floorRightPath = new FileInputStream("src/main/resources/fr/sae/terraria/tiles/floor-right.png");
+ } catch (FileNotFoundException e) { throw new RuntimeException(e); }
+ Image floorRightImg = new Image(floorRightPath, tileWidth.get(), tileHeight.get(), false, false);
+
+ InputStream stonePath = Terraria.class.getResourceAsStream("tiles/rock-fill.png");
+ if (stonePath == null) try {
+ stonePath = new FileInputStream("src/main/resources/fr/sae/terraria/tiles/rock-fill.png");
+ } catch (FileNotFoundException e) { throw new RuntimeException(e); }
+ Image stoneImg = new Image(stonePath, tileWidth.get(), tileHeight.get(), false, false);
+
+ InputStream dirtPath = Terraria.class.getResourceAsStream("tiles/dirt-top.png");
+ if (dirtPath == null) try {
+ dirtPath = new FileInputStream("src/main/resources/fr/sae/terraria/tiles/dirt-top.png");
+ } catch (FileNotFoundException e) { throw new RuntimeException(e); }
+ Image dirtImg = new Image(dirtPath, tileWidth.get(), tileHeight.get(), false, false);
+
+ InputStream playerPath = Terraria.class.getResourceAsStream("sprites/player/player_idle.png");
+ if (playerPath == null) try {
+ playerPath = new FileInputStream("src/main/resources/fr/sae/terraria/sprites/player/player_idle.png");
+ } catch (FileNotFoundException e) { throw new RuntimeException(e); }
+
+ for (int y = 0; y < tiles.getHeight() ; y++)
+ for (int x = 0 ; x < tiles.getWidth() ; x++)
+ switch (tiles.getTile(y,x))
+ {
+ case TileMaps.STONE:
+ Stone stoneSprite = new Stone(x*tileWidth.get(), y*tileHeight.get());
+ stoneSprite.setRect((int) stoneImg.getWidth(), (int) stoneImg.getHeight());
+ display.getChildren().add(createImageView(stoneSprite, stoneImg));
+ environment.getEntities().add(stoneSprite);
+ break;
+ case TileMaps.DIRT:
+ Dirt dirtSprite = new Dirt(x*tileWidth.get(), y*tileHeight.get());
+ dirtSprite.setRect((int) dirtImg.getWidth(), (int) dirtImg.getHeight());
+ display.getChildren().add(createImageView(dirtSprite, dirtImg));
+ environment.getEntities().add(dirtSprite);
+ break;
+ case TileMaps.FLOOR_TOP:
+ Dirt floorTopSprite = new Dirt(x*tileWidth.get(), y*tileHeight.get());
+ floorTopSprite.setRect((int) floorTopImg.getWidth(), (int) floorTopImg.getHeight());
+ display.getChildren().add(createImageView(floorTopSprite, floorTopImg));
+ environment.getEntities().add(floorTopSprite);
+ break;
+ case TileMaps.FLOOR_LEFT:
+ Dirt floorLeftSprite = new Dirt(x*tileWidth.get(), y*tileHeight.get());
+ floorLeftSprite.setRect((int) floorLeftImg.getWidth(), (int) floorLeftImg.getHeight());
+ display.getChildren().add(createImageView(floorLeftSprite, floorLeftImg));
+ environment.getEntities().add(floorLeftSprite);
+ break;
+ case TileMaps.FLOOR_RIGHT:
+ Dirt floorRightSprite = new Dirt(x*tileWidth.get(), y*tileHeight.get());
+ floorRightSprite.setRect((int) floorRightImg.getWidth(), (int) floorRightImg.getHeight());
+ display.getChildren().add(createImageView(floorRightSprite, floorRightImg));
+ environment.getEntities().add(floorRightSprite);
+ break;
+ }
+
+ ImageView playerImgView = new ImageView(new Image(playerPath, tileWidth.get(), tileHeight.get()*2, false, false));
+ environment.getPlayer().setRect((int) playerImgView.getFitWidth(), (int) playerImgView.getFitHeight());
+ playerImgView.translateYProperty().bind(environment.getPlayer().getYProperty());
+ playerImgView.translateXProperty().bind(environment.getPlayer().getXProperty());
+ display.getChildren().add(playerImgView);
+ }
+
+ private ImageView createImageView(Entity entity, Image img)
+ {
+ ImageView imageView = new ImageView(img);
+ imageView.translateXProperty().bind(entity.getXProperty());
+ imageView.translateYProperty().bind(entity.getYProperty());
+
+ return imageView;
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/fr/sae/terraria/modele/Environment.java b/src/main/java/fr/sae/terraria/modele/Environment.java
new file mode 100644
index 0000000..adb3e4a
--- /dev/null
+++ b/src/main/java/fr/sae/terraria/modele/Environment.java
@@ -0,0 +1,74 @@
+package fr.sae.terraria.modele;
+
+import fr.sae.terraria.modele.entities.*;
+import fr.sae.terraria.modele.entities.entity.Entity;
+import javafx.animation.KeyFrame;
+import javafx.animation.Timeline;
+import javafx.scene.input.KeyCode;
+import javafx.util.Duration;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map;
+
+import static javafx.scene.input.KeyCode.D;
+import static javafx.scene.input.KeyCode.Q;
+
+
+public class Environment
+{
+ private Player player;
+ private ArrayList entities;
+ private Map keysInput = new HashMap<>();
+
+ private int ticks = 0;
+
+
+ public Environment()
+ {
+ entities = new ArrayList<>();
+
+ player = new Player(0,0, 3, 1);
+ player.setPv(20);
+ player.setVelocity(2);
+
+ gameLoop();
+ }
+
+ private void gameLoop()
+ {
+ Timeline loop = new Timeline();
+ loop.setCycleCount(Timeline.INDEFINITE);
+
+ KeyFrame keyFrame = new KeyFrame(Duration.seconds(0.017), (ev -> {
+ eventInput();
+ getPlayer().updates();
+
+ ticks++;
+ }));
+
+ loop.getKeyFrames().add(keyFrame);
+ loop.play();
+ }
+
+ public void eventInput()
+ {
+ int countKeys[] = new int[1];
+ keysInput.forEach((key, value) -> {
+ if (key == D && value)
+ getPlayer().moveRight();
+ if (key == Q && value)
+ getPlayer().moveLeft();
+
+ if (!value)
+ countKeys[0]++;
+ if (countKeys[0] == keysInput.size())
+ getPlayer().idle();
+ });
+ }
+
+
+ public Map getKeysInput() { return keysInput; }
+ public ArrayList getEntities() { return entities; }
+ public Player getPlayer() { return player; }
+}
diff --git a/src/main/java/fr/sae/terraria/modele/TileMaps.java b/src/main/java/fr/sae/terraria/modele/TileMaps.java
new file mode 100644
index 0000000..60ff8e7
--- /dev/null
+++ b/src/main/java/fr/sae/terraria/modele/TileMaps.java
@@ -0,0 +1,119 @@
+package fr.sae.terraria.modele;
+
+import com.google.gson.stream.JsonReader;
+
+import java.io.FileReader;
+
+
+public class TileMaps
+{
+ public final static int tileDefaultSize = 16;
+ public final static int SKY = 0;
+ public final static int STONE = 1;
+ public final static int DIRT = 2;
+ public final static int FLOOR_TOP = 3;
+ public final static int FLOOR_LEFT = 4;
+ public final static int FLOOR_RIGHT = 5;
+
+ private int[][] map;
+ private int w;
+ private int h;
+
+
+ /**
+ * Compte la taille de la carte et ensuite la charge dans
+ * la variable map
+ *
+ * @param path Le chemin depuis le root (src)
+ */
+ public void load(String path)
+ {
+ boolean widthSave = false;
+ int i = 0;
+ int j = 0;
+
+ try (FileReader fileReader = new FileReader(path);
+ JsonReader jsonReader = new JsonReader(fileReader))
+ {
+ jsonReader.beginObject();
+ // Deduit la taille de la carte.
+ while (jsonReader.hasNext())
+ {
+ h++;
+
+ jsonReader.nextName();
+
+ jsonReader.beginArray();
+ while (jsonReader.hasNext()) {
+ jsonReader.nextInt();
+ if (!widthSave) w++;
+ }
+ jsonReader.endArray();
+
+ widthSave = true;
+ }
+ jsonReader.endObject();
+ } catch (Exception e) { e.printStackTrace(); }
+
+
+ try (FileReader fileReader = new FileReader(path);
+ JsonReader jsonReader = new JsonReader(fileReader))
+ {
+ map = new int[h][w];
+ // Ecrit la carte dans la mémoire.
+ jsonReader.beginObject();
+ while (jsonReader.hasNext())
+ {
+ jsonReader.nextName();
+
+ jsonReader.beginArray();
+ while (jsonReader.hasNext()) {
+ map[i][j] = jsonReader.nextInt();
+ j++;
+ }
+ jsonReader.endArray();
+
+ j = 0;
+ i++;
+ }
+ jsonReader.endObject();
+ } catch (Exception e) { e.printStackTrace(); }
+ }
+
+ /**
+ * Crée une variable de la même taille que la carte couramment utilisé
+ * La copie et renvoie la variable qui a copié la carte du jeu
+ *
+ * @return Un tableau 2D qui contient la carte qui est utilisé dans le jeu.
+ */
+ public int[][] copy()
+ {
+ int[][] mapCopy = new int[map.length][map[0].length];
+
+ for (int i = 0; i < this.map.length; i++)
+ for (int j = 0; j < this.map[i].length; j++)
+ mapCopy[i][j] = this.map[i][j];
+
+ return mapCopy;
+ }
+
+ public void clear()
+ {
+ for (int y = 0; y < getHeight(); y++)
+ for (int x = 0; x < getWidth(); x++)
+ map[y][x] = SKY;
+ }
+
+ public void fill(int tileIndex)
+ {
+ for (int y = 0; y < getHeight(); y++)
+ for (int x = 0; x < getWidth(); x++)
+ map[y][x] = tileIndex;
+ }
+
+
+ public int getHeight() { return map.length; }
+ public int getWidth() { return map[0].length; }
+ public int getTile(int y, int x) { return map[y][x]; }
+ public void setTile(int tileIndex, int y, int x) { map[y][x] = tileIndex; }
+}
diff --git a/src/main/java/fr/sae/terraria/modele/blocks/Block.java b/src/main/java/fr/sae/terraria/modele/blocks/Block.java
new file mode 100644
index 0000000..1517d84
--- /dev/null
+++ b/src/main/java/fr/sae/terraria/modele/blocks/Block.java
@@ -0,0 +1,16 @@
+package fr.sae.terraria.modele.blocks;
+
+import fr.sae.terraria.modele.entities.entity.Entity;
+
+
+public abstract class Block extends Entity
+{
+
+
+ public Block(int x, int y)
+ {
+ super(x, y);
+ }
+
+ public abstract void updates();
+}
diff --git a/src/main/java/fr/sae/terraria/modele/blocks/Dirt.java b/src/main/java/fr/sae/terraria/modele/blocks/Dirt.java
new file mode 100644
index 0000000..aab69c1
--- /dev/null
+++ b/src/main/java/fr/sae/terraria/modele/blocks/Dirt.java
@@ -0,0 +1,12 @@
+package fr.sae.terraria.modele.blocks;
+
+
+public class Dirt extends Block
+{
+ public Dirt(int x, int y)
+ {
+ super(x, y);
+ }
+
+ public void updates() {}
+}
diff --git a/src/main/java/fr/sae/terraria/modele/blocks/Grass.java b/src/main/java/fr/sae/terraria/modele/blocks/Grass.java
new file mode 100644
index 0000000..44d996a
--- /dev/null
+++ b/src/main/java/fr/sae/terraria/modele/blocks/Grass.java
@@ -0,0 +1,14 @@
+package fr.sae.terraria.modele.blocks;
+
+public class Grass extends Block
+{
+ public Grass(int x, int y){
+ super(x, y);
+
+ }
+
+ @Override
+ public void updates() {
+
+ }
+}
diff --git a/src/main/java/fr/sae/terraria/modele/blocks/Stone.java b/src/main/java/fr/sae/terraria/modele/blocks/Stone.java
new file mode 100644
index 0000000..081974c
--- /dev/null
+++ b/src/main/java/fr/sae/terraria/modele/blocks/Stone.java
@@ -0,0 +1,23 @@
+package fr.sae.terraria.modele.blocks;
+
+
+public class Stone extends Block
+{
+ /*
+ TODO: Mettre en place un drop aléatoire de charbon
+ Si le joueur craft la Stone, il ne drop pas de charbon
+ Mettre une durabilité
+ Le nombre de pierre qui est drop est entre 1 et 4
+ (Optionnel) Faire un bruitage lorsque le joueur le casse
+ (Optionnel) Faire des particules de pierre lorsque on est en train de le casser
+ */
+ public Stone(int x, int y){
+ super(x, y);
+
+ }
+
+ @Override
+ public void updates() {
+
+ }
+}
diff --git a/src/main/java/fr/sae/terraria/modele/blocks/TallGrass.java b/src/main/java/fr/sae/terraria/modele/blocks/TallGrass.java
new file mode 100644
index 0000000..4a0c3b2
--- /dev/null
+++ b/src/main/java/fr/sae/terraria/modele/blocks/TallGrass.java
@@ -0,0 +1,14 @@
+package fr.sae.terraria.modele.blocks;
+
+public class TallGrass
+{
+ /*
+ TODO: Donne de la fibre au joueur de manière aléatoire
+ Peut ne pas drop ou drop juste 1 (Pas plus)
+ (Optionnel) Faire que l'herbe au passage du joueur provoque un bruitage
+ (Optionnel) Faire une animation lorsque le joueur passe dedans
+ */
+ public TallGrass(int x, int y){
+
+ }
+}
diff --git a/src/main/java/fr/sae/terraria/modele/entities/Arrow.java b/src/main/java/fr/sae/terraria/modele/entities/Arrow.java
new file mode 100644
index 0000000..33f1583
--- /dev/null
+++ b/src/main/java/fr/sae/terraria/modele/entities/Arrow.java
@@ -0,0 +1,24 @@
+package fr.sae.terraria.modele.entities;
+
+
+import fr.sae.terraria.modele.entities.entity.Entity;
+
+public class Arrow extends Entity
+{
+
+
+ public Arrow(int x, int y, int velocity)
+ {
+ super(x, y);
+
+ this.velocity = velocity;
+ }
+
+ public void updates()
+ {
+ this.setX(this.x.get() + this.offset[0] * this.velocity);
+ this.setY(this.y.get() + this.offset[1] * this.velocity);
+
+ this.rect.update(x.get(), y.get());
+ }
+}
diff --git a/src/main/java/fr/sae/terraria/modele/entities/Player.java b/src/main/java/fr/sae/terraria/modele/entities/Player.java
new file mode 100644
index 0000000..308180d
--- /dev/null
+++ b/src/main/java/fr/sae/terraria/modele/entities/Player.java
@@ -0,0 +1,39 @@
+package fr.sae.terraria.modele.entities;
+
+
+import fr.sae.terraria.modele.entities.entity.Entity;
+
+public class Player extends Entity
+{
+ private double frame; // TODO faire une animation
+
+
+ public Player(int x, int y, int pv, int velocity)
+ {
+ super(x, y);
+
+ this.pv = pv;
+ this.velocity = velocity;
+ this.frame = 1;
+ }
+
+ public void moveRight() {
+ this.offset[0] = 1;
+ }
+
+ public void moveLeft() { this.offset[0] = -1; }
+
+ public void idle(){ this.offset[0] = 0; this.offset[1] =0;}
+
+ public void updates(){
+ this.setX(this.x.get() + this.offset[0] * this.velocity);
+ this.setY(this.y.get() + this.offset[1] * this.velocity);
+
+ // TODO faire les frame
+ if(frame == 4) {
+ frame = 0;
+ }
+
+ this.rect.update(x.get(), y.get());
+ }
+}
diff --git a/src/main/java/fr/sae/terraria/modele/entities/Rabbit.java b/src/main/java/fr/sae/terraria/modele/entities/Rabbit.java
new file mode 100644
index 0000000..73a43f3
--- /dev/null
+++ b/src/main/java/fr/sae/terraria/modele/entities/Rabbit.java
@@ -0,0 +1,34 @@
+package fr.sae.terraria.modele.entities;
+
+
+import fr.sae.terraria.modele.entities.entity.Entity;
+
+public class Rabbit extends Entity
+{
+ private int frame;
+
+
+ public Rabbit(int x, int y, int pv, double velocity)
+ {
+ super(x, y);
+ this.pv = pv;
+ this.velocity = velocity;
+ }
+
+ public void updates()
+ {
+ this.setX(this.x.get() + this.offset[0] * this.velocity);
+ this.setY(this.y.get() + this.offset[1] * this.velocity);
+
+ if(frame == 4) {
+ frame = 0;
+ }//TODO faire les frame
+
+ this.rect.update(x.get(), y.get());
+ }
+
+}
+
+
+
+
diff --git a/src/main/java/fr/sae/terraria/modele/entities/Slime.java b/src/main/java/fr/sae/terraria/modele/entities/Slime.java
new file mode 100644
index 0000000..d21265c
--- /dev/null
+++ b/src/main/java/fr/sae/terraria/modele/entities/Slime.java
@@ -0,0 +1,32 @@
+package fr.sae.terraria.modele.entities;
+
+
+import fr.sae.terraria.modele.entities.entity.Entity;
+
+public class Slime extends Entity
+{
+ private int frame;
+
+
+ public Slime(int x, int y, int pv, double velocity)
+ {
+ super(x, y);
+
+ this.pv = pv;
+ this.velocity = velocity;
+ }
+
+ public void updates()
+ {
+ this.setX(this.x.get() + this.offset[0] * this.velocity);
+ this.setY(this.y.get() + this.offset[1] * this.velocity);
+
+ // TODO: faire les frame
+ if(frame == 4) {
+ frame = 0;
+ }
+
+ this.rect.update(x.get(), y.get());
+ }
+
+}
diff --git a/src/main/java/fr/sae/terraria/modele/entities/entity/Entity.java b/src/main/java/fr/sae/terraria/modele/entities/entity/Entity.java
new file mode 100644
index 0000000..c6e2501
--- /dev/null
+++ b/src/main/java/fr/sae/terraria/modele/entities/entity/Entity.java
@@ -0,0 +1,44 @@
+package fr.sae.terraria.modele.entities.entity;
+
+import javafx.beans.property.DoubleProperty;
+import javafx.beans.property.SimpleDoubleProperty;
+
+
+public abstract class Entity
+{
+ protected Rect rect;
+
+ protected DoubleProperty x;
+ protected DoubleProperty y;
+
+ protected int[] offset;
+ protected int pv = 3;
+ protected double velocity = 1;
+
+
+ public Entity(int x, int y)
+ {
+ this.x = new SimpleDoubleProperty(x);
+ this.y = new SimpleDoubleProperty(y);
+
+ this.offset = new int[2];
+ }
+
+ public abstract void updates();
+
+ public DoubleProperty getXProperty() { return x; }
+ public DoubleProperty getYProperty(){ return y; }
+ public Rect getRect() { return rect; }
+ public double getX() { return x.get(); }
+ public double getY() { return y.get(); }
+ public int getPv() { return pv; }
+ public double getVelocity() { return velocity; }
+
+ public void setPv(int pv) { this.pv = pv; }
+ public void setVelocity(double velocity) { this.velocity = velocity; }
+ public void setX(double x) { this.x.setValue(x); }
+ public void setY(double y) { this.y.setValue(y); }
+ public void setRect(int width, int height) { this.rect = new Rect(x.get(), y.get(), width, height); }
+}
+
+
diff --git a/src/main/java/fr/sae/terraria/modele/entities/entity/Rect.java b/src/main/java/fr/sae/terraria/modele/entities/entity/Rect.java
new file mode 100644
index 0000000..195eb13
--- /dev/null
+++ b/src/main/java/fr/sae/terraria/modele/entities/entity/Rect.java
@@ -0,0 +1,25 @@
+package fr.sae.terraria.modele.entities.entity;
+
+
+import javafx.geometry.Rectangle2D;
+
+public class Rect
+{
+ private Rectangle2D rect;
+
+ private int width;
+ private int height;
+
+
+ public Rect(double x, double y, int width, int height)
+ {
+ this.rect = new Rectangle2D(x, y, width, height);
+
+ this.width = width;
+ this.height = height;
+ }
+
+ public void update(double x, double y) { this.rect = new Rectangle2D(x, y, width, height); }
+
+ public Rectangle2D get() { return this.rect; }
+}
diff --git a/src/main/java/fr/sae/terraria/modele/tools/Axe.java b/src/main/java/fr/sae/terraria/modele/tools/Axe.java
new file mode 100644
index 0000000..96c474d
--- /dev/null
+++ b/src/main/java/fr/sae/terraria/modele/tools/Axe.java
@@ -0,0 +1,9 @@
+package fr.sae.terraria.modele.tools;
+
+
+public class Axe extends Tool
+{
+ public Axe(){
+
+ }
+}
diff --git a/src/main/java/fr/sae/terraria/modele/tools/Bow.java b/src/main/java/fr/sae/terraria/modele/tools/Bow.java
new file mode 100644
index 0000000..28f58ca
--- /dev/null
+++ b/src/main/java/fr/sae/terraria/modele/tools/Bow.java
@@ -0,0 +1,9 @@
+package fr.sae.terraria.modele.tools;
+
+
+public class Bow
+{
+ public Bow(){
+
+ }
+}
diff --git a/src/main/java/fr/sae/terraria/modele/tools/Pickaxe.java b/src/main/java/fr/sae/terraria/modele/tools/Pickaxe.java
new file mode 100644
index 0000000..60e28f5
--- /dev/null
+++ b/src/main/java/fr/sae/terraria/modele/tools/Pickaxe.java
@@ -0,0 +1,9 @@
+package fr.sae.terraria.modele.tools;
+
+
+public class Pickaxe extends Tool
+{
+ public Pickaxe(){
+
+ }
+}
diff --git a/src/main/java/fr/sae/terraria/modele/tools/Sword.java b/src/main/java/fr/sae/terraria/modele/tools/Sword.java
new file mode 100644
index 0000000..75fa89d
--- /dev/null
+++ b/src/main/java/fr/sae/terraria/modele/tools/Sword.java
@@ -0,0 +1,9 @@
+package fr.sae.terraria.modele.tools;
+
+
+public class Sword
+{
+ public Sword(){
+
+ }
+}
diff --git a/src/main/java/fr/sae/terraria/modele/tools/Tool.java b/src/main/java/fr/sae/terraria/modele/tools/Tool.java
new file mode 100644
index 0000000..b3f45bb
--- /dev/null
+++ b/src/main/java/fr/sae/terraria/modele/tools/Tool.java
@@ -0,0 +1,9 @@
+package fr.sae.terraria.modele.tools;
+
+
+public class Tool
+{
+ public Tool(){
+
+ }
+}
diff --git a/src/main/java/module-info.java b/src/main/java/module-info.java
index c233fed..7b01f17 100644
--- a/src/main/java/module-info.java
+++ b/src/main/java/module-info.java
@@ -1,8 +1,13 @@
module fr.sae.terraria {
requires javafx.controls;
requires javafx.fxml;
+ requires com.google.gson;
opens fr.sae.terraria to javafx.fxml;
exports fr.sae.terraria;
+ exports fr.sae.terraria.controller;
+ opens fr.sae.terraria.controller to javafx.fxml;
+ exports fr.sae.terraria.modele;
+ opens fr.sae.terraria.modele to javafx.fxml;
}
\ No newline at end of file
diff --git a/src/main/resources/fr/sae/terraria/hello-view.fxml b/src/main/resources/fr/sae/terraria/hello-view.fxml
deleted file mode 100644
index 55dd2ca..0000000
--- a/src/main/resources/fr/sae/terraria/hello-view.fxml
+++ /dev/null
@@ -1,16 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/main/resources/fr/sae/terraria/map_0.json b/src/main/resources/fr/sae/terraria/map_0.json
deleted file mode 100644
index e69de29..0000000
diff --git a/src/main/resources/fr/sae/terraria/maps/map_0.json b/src/main/resources/fr/sae/terraria/maps/map_0.json
new file mode 100644
index 0000000..8ec3894
--- /dev/null
+++ b/src/main/resources/fr/sae/terraria/maps/map_0.json
@@ -0,0 +1,19 @@
+{
+ "0": [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
+ "1": [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
+ "2": [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
+ "3": [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
+ "4": [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
+ "5": [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
+ "6": [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
+ "7": [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
+ "8": [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
+ "9": [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,5,0,0,0,0,0,0,0,0,0,0,0,0,0],
+ "10": [4,5,0,0,0,0,0,0,0,0,0,0,0,0,4,2,2,5,0,0,0,0,0,0,0,0,0,0,0,0],
+ "11": [2,2,3,5,0,0,0,0,0,0,4,3,3,3,2,1,1,2,3,3,5,0,0,0,0,0,0,0,0,0],
+ "12": [1,1,2,2,3,3,3,3,3,3,2,2,2,2,1,1,1,1,2,2,2,3,3,3,5,0,4,3,3,3],
+ "13": [1,1,1,1,2,2,2,2,2,2,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,3,2,2,2,2],
+ "14": [1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,1,1,1,1],
+ "15": [1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1],
+ "16": [1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]
+}
\ No newline at end of file
diff --git a/src/main/resources/fr/sae/terraria/sprites/player/player_idle.png b/src/main/resources/fr/sae/terraria/sprites/player/player_idle.png
new file mode 100644
index 0000000..a69f97d
Binary files /dev/null and b/src/main/resources/fr/sae/terraria/sprites/player/player_idle.png differ
diff --git a/src/main/resources/fr/sae/terraria/tiles/dirt-left.png b/src/main/resources/fr/sae/terraria/tiles/dirt-left.png
new file mode 100644
index 0000000..ba2ee39
Binary files /dev/null and b/src/main/resources/fr/sae/terraria/tiles/dirt-left.png differ
diff --git a/src/main/resources/fr/sae/terraria/tiles/dirt-top.png b/src/main/resources/fr/sae/terraria/tiles/dirt-top.png
new file mode 100644
index 0000000..d89d568
Binary files /dev/null and b/src/main/resources/fr/sae/terraria/tiles/dirt-top.png differ
diff --git a/src/main/resources/fr/sae/terraria/tiles/floor-left.png b/src/main/resources/fr/sae/terraria/tiles/floor-left.png
new file mode 100644
index 0000000..09593e9
Binary files /dev/null and b/src/main/resources/fr/sae/terraria/tiles/floor-left.png differ
diff --git a/src/main/resources/fr/sae/terraria/tiles/floor-right.png b/src/main/resources/fr/sae/terraria/tiles/floor-right.png
new file mode 100644
index 0000000..32eb346
Binary files /dev/null and b/src/main/resources/fr/sae/terraria/tiles/floor-right.png differ
diff --git a/src/main/resources/fr/sae/terraria/tiles/floor-top.png b/src/main/resources/fr/sae/terraria/tiles/floor-top.png
new file mode 100644
index 0000000..f6d389a
Binary files /dev/null and b/src/main/resources/fr/sae/terraria/tiles/floor-top.png differ
diff --git a/src/main/resources/fr/sae/terraria/tiles/rock-bottom.png b/src/main/resources/fr/sae/terraria/tiles/rock-bottom.png
new file mode 100644
index 0000000..40b186b
Binary files /dev/null and b/src/main/resources/fr/sae/terraria/tiles/rock-bottom.png differ
diff --git a/src/main/resources/fr/sae/terraria/tiles/rock-fill.png b/src/main/resources/fr/sae/terraria/tiles/rock-fill.png
new file mode 100644
index 0000000..17d3621
Binary files /dev/null and b/src/main/resources/fr/sae/terraria/tiles/rock-fill.png differ
diff --git a/src/main/resources/fr/sae/terraria/tiles/rock-top_0.png b/src/main/resources/fr/sae/terraria/tiles/rock-top_0.png
new file mode 100644
index 0000000..101b7d1
Binary files /dev/null and b/src/main/resources/fr/sae/terraria/tiles/rock-top_0.png differ
diff --git a/src/main/resources/fr/sae/terraria/vue/game.css b/src/main/resources/fr/sae/terraria/vue/game.css
new file mode 100644
index 0000000..d87cf98
--- /dev/null
+++ b/src/main/resources/fr/sae/terraria/vue/game.css
@@ -0,0 +1,17 @@
+#sky
+{
+ -fx-background-color: #87CEEB;
+}
+
+#textArea
+{
+ -fx-background-color: black;
+ -fx-font-family: Impact;
+ -fx-alignment: center;
+}
+
+#text
+{
+ -fx-fill: white;
+ -fx-font-size: 23px;
+}
\ No newline at end of file
diff --git a/src/main/resources/fr/sae/terraria/vue/game.fxml b/src/main/resources/fr/sae/terraria/vue/game.fxml
new file mode 100644
index 0000000..7529a44
--- /dev/null
+++ b/src/main/resources/fr/sae/terraria/vue/game.fxml
@@ -0,0 +1,35 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+