Skip to content
Snippets Groups Projects
Commit bf48caa6 authored by SYMKO TRISTAN's avatar SYMKO TRISTAN
Browse files

update

parent 599691bc
Branches
No related merge requests found
......@@ -3,12 +3,13 @@
# Variables
JAVAC = javac
JAVA = java
JAR = jar
SRC_DIR = ./src/App
BIN_DIR = ./bin
PACKAGE_MAIN = paquetMain
PACKAGE_SRC = paquetSrc
MAIN_CLASS = Launch
JAR_NAME = 'Monstre Hunter.jar'
# Liste des fichiers source Java
JAVA_FILES := $(wildcard $(SRC_DIR)/$(PACKAGE_MAIN)/*.java $(SRC_DIR)/$(PACKAGE_SRC)/*.java)
......@@ -26,7 +27,12 @@ $(BIN_DIR):
run:
$(JAVA) -cp $(BIN_DIR) $(PACKAGE_MAIN).$(MAIN_CLASS)
# Cible pour nettoyer les fichiers compilés
# Cible pour créer un fichier JAR du projet
.PHONY: jar
jar: all
$(JAR) cvfe $(JAR_NAME) $(PACKAGE_MAIN).$(MAIN_CLASS) -C $(BIN_DIR) .
# Cible pour nettoyer les fichiers compilés et le fichier JAR
.PHONY: clean
clean:
rm -rf $(BIN_DIR)
\ No newline at end of file
rm -rf $(BIN_DIR) $(JAR_NAME)
\ No newline at end of file
package paquetSrc;
import java.util.Scanner;
public class Game {
private Level level;
public boolean isEnd = false;
......@@ -59,6 +57,7 @@ public class Game {
default:
break;
}
deplacerMonstres();
}
public void combat(Player joueur, Monster monstre) {
......@@ -76,6 +75,35 @@ public class Game {
}
}
public void deplacerMonstres() {
for (int i = 0; i < level.monstres.length; i++) {
Monster monstre = level.monstres[i];
if (monstre != null && !monstre.getMort()) {
int dx = level.joueur.getX() - monstre.getX();
int dy = level.joueur.getY() - monstre.getY();
// Choix de la direction en fonction de la distance
int newX = monstre.getX();
int newY = monstre.getY();
if (Math.abs(dx) > Math.abs(dy)) {
newX += Integer.signum(dx);
} else {
newY += Integer.signum(dy);
}
// Vérification si la nouvelle position est valide
if (level.getChar(newX, newY) == ' ') {
level.setChar(monstre.getX(), monstre.getY(), ' ');
monstre.setPosition(newX, newY);
level.setChar(newX, newY, '$');
} else if (level.getChar(newX, newY) == 'P') {
combat(level.joueur, monstre);
}
}
}
}
// Changement de niveau
public void checkNext(int x, int y) {
switch (level.getChar(x, y)) {
......
......@@ -51,6 +51,17 @@ public class RefreshThread implements Runnable {
try {
// Attendre avant le prochain rafraîchissement
Thread.sleep(REFRESH_INTERVAL);
if (game.isEnd()) {
// Attente de 5 secondes avant de quitter
try {
Thread.sleep(3500); // 5000 ms = 5 secondes
} catch (InterruptedException e) {
e.printStackTrace();
}
// Fermeture du programme
System.exit(0);
}
} catch (InterruptedException e) {
e.printStackTrace();
}
......
......@@ -2,7 +2,7 @@ i##########
# $ #
# $ $ #
# #
# $ #
# #
# #
# #
# P .#
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment