From 7677c6ec6355c02e974d59615ea89289cba115c2 Mon Sep 17 00:00:00 2001 From: streaper2 Date: Mon, 27 May 2024 08:25:38 +0200 Subject: [PATCH] New branch --- .classpath | 10 ++ .project | 17 +++ .settings/org.eclipse.core.resources.prefs | 2 + .settings/org.eclipse.jdt.core.prefs | 14 +++ bin/eXplorer/LevelGenerator.class | Bin 0 -> 2929 bytes bin/eXplorer/Main.class | Bin 0 -> 517 bytes bin/eXplorer/Player.class | Bin 0 -> 499 bytes src/eXplorer/LevelGenerator.java | 119 +++++++++++++++++++++ src/eXplorer/Main.java | 19 ++++ src/eXplorer/Player.java | 20 ++++ 10 files changed, 201 insertions(+) create mode 100644 .classpath create mode 100644 .project create mode 100644 .settings/org.eclipse.core.resources.prefs create mode 100644 .settings/org.eclipse.jdt.core.prefs create mode 100644 bin/eXplorer/LevelGenerator.class create mode 100644 bin/eXplorer/Main.class create mode 100644 bin/eXplorer/Player.class create mode 100644 src/eXplorer/LevelGenerator.java create mode 100644 src/eXplorer/Main.java create mode 100644 src/eXplorer/Player.java diff --git a/.classpath b/.classpath new file mode 100644 index 0000000..57bca72 --- /dev/null +++ b/.classpath @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/.project b/.project new file mode 100644 index 0000000..9651472 --- /dev/null +++ b/.project @@ -0,0 +1,17 @@ + + + eXplorer + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000..99f26c0 --- /dev/null +++ b/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/=UTF-8 diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..8c9943d --- /dev/null +++ b/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,14 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=17 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=17 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning +org.eclipse.jdt.core.compiler.release=enabled +org.eclipse.jdt.core.compiler.source=17 diff --git a/bin/eXplorer/LevelGenerator.class b/bin/eXplorer/LevelGenerator.class new file mode 100644 index 0000000000000000000000000000000000000000..72f34b81c33c890606c7b25a29a0fc4ea95af129 GIT binary patch literal 2929 zcmaJ@-%lLZ75?t-?9R^Y0ycPT90;BS$AvY9#4(!fs zW(RDyQu~7BJVnY|tyB%PQdfzrC~<5Oxe-yM%ep&}x1z<#4r@_gGLn6Ovu(wObqz7=@B3PoVgqP1cTlq|O} zaA{%D&IJN$(OM4dWnVyy3nWUOTUZX4v7F@xw!psG*@^9I*}!+)!jM3G*m0fUv_Pz9 ze7tu?KpFA!wvH&8Q_#^O5bf!m(IBulg&5*eYD+;yT&HBDupbBLuTYPVe)jkD?&e9} zJD5TOnn25hDQ}q& z8+H5~Z(xex1%%MH%0sOzT7L=y_&$qPwwCM>&&^rEWhW?7ss@%DFp2#V-KX)_aU3U9 zyhKdHIG?ng!bxOU+KO~nav4F-(rIKB+N@x7Sa@lr+(d#+85;&fl zz@Wh3q*XBk&oirKt5l+7R!UaRHm`A2HLo#hGbq|-!CA3gvuybV$2EzSS+FWPPGMM* zBGbxZ_9yT|lC3*|Gn}fD4I?R>!zing^W4C4T;?6`nPuW{wjzQt3DO0EL@0K{B7s+F zsFJ`0CzC{!Aqhlg$!AT|93 z_F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~sFYG^wcH*X-2G$}xfji{uQCqaliB|D6&jXq_h(J;PtM7PicHLS=SKh><)9FUTY_bP8im~oNw ZKCWHb@xt-#aIDfNh>ySuuH)x8_#X;QX-5D6 literal 0 HcmV?d00001 diff --git a/bin/eXplorer/Main.class b/bin/eXplorer/Main.class new file mode 100644 index 0000000000000000000000000000000000000000..43b95f355a6918a137efe8bbd3a3fdf670c3a550 GIT binary patch literal 517 zcmZutO;5r=5Pb`UO8F|HAbusp3ut2F8TCSp!{a{=6(VUDu kdBgTV=gh2s@}zrOnyJ9<5~9r#gXyA94j{{Qv*} literal 0 HcmV?d00001 diff --git a/bin/eXplorer/Player.class b/bin/eXplorer/Player.class new file mode 100644 index 0000000000000000000000000000000000000000..539a5b37b35c45f18b7090158d7fa841597feae6 GIT binary patch literal 499 zcmZ9I%TB^T7=_QY1uRq$@XjT=gPO<#c-fekkPtP|5L}ir(UQ`V(h_+r7sSMc58y)? z&$J{aHfiVl|9|GpH~s$k`~q-=b^)3|MULiv7|E#j;5#cB6<`SLOr53E^PS+OcR!v= zHx@8uFi9dOaHW9g3mEfoG0K)_f&8Txc=5GBuG8;#hwR^k6Iq0gZ3`yK0(z%AG{I;K zIpme9Stw*`*TNR^WEpsYyh~ zVA=W_728;&sy=nQp;VLVJ>9pbd`ts(8%#HuS7u#j(jhFgSnYFqk|pARUG=naM5jpA gF_lK$pf@8pV_(h0-yxZ~mWEl`a1$obq*X)f7hIxCOaK4? literal 0 HcmV?d00001 diff --git a/src/eXplorer/LevelGenerator.java b/src/eXplorer/LevelGenerator.java new file mode 100644 index 0000000..7bb4f92 --- /dev/null +++ b/src/eXplorer/LevelGenerator.java @@ -0,0 +1,119 @@ +package eXplorer; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Random; +import java.lang.*; + + +public class LevelGenerator { + + private int hauteur; + private int longueur; + private String[][] carte; + + //constructeur + public LevelGenerator(int pHauteur, int pLongueur) { + this.hauteur = pHauteur; + this.longueur = pLongueur; + this.carte = generate(); + } + + + public String[][] generate() { + String[][] carte = new String[this.hauteur][this.longueur]; + int[] wall = new int[3]; + int[] wallPorte = new int[3]; + int sortie = 5; + int minGap = 3; // Minimum gap between walls + int margin = 3; // Margin from the edges + + //génération des positions des portes + for (int i = 0; i < wallPorte.length; i++) { + int max = this.hauteur - 2; // Ajusté pour éviter les bords + int min = 1; // Évite les bords + int range = max - min + 1; + int dernierMur = (int) (Math.random() * range) + min; + if(dernierMur != this.longueur-2) { + wallPorte[i] = dernierMur; + } + + //il sera généré 3 fois mais pas grave + sortie = (int) (Math.random() * range) + min; + System.out.println("WallPorte " + i + ": " + wallPorte[i]); + } + + + /** + * Generation des murs interieur + */ + // Ensure there is enough space to place the walls with the given margin and gap + if (this.longueur - 2 * margin < (wall.length - 1) * minGap) { + throw new IllegalArgumentException("Map too small to place walls with the given margin and gap"); + } + + int availableSpace = this.longueur - 2 * margin - (minGap * (wall.length - 1)); + int basePosition = margin; + + + for (int i = 0; i < wall.length; i++) { + wall[i] = basePosition + (int)(Math.random() * availableSpace / wall.length) + (i * (minGap + 1)); + basePosition = wall[i] + minGap; + System.out.println("Wall " + i + ": " + wall[i]); + } + + + + for (int i = 0; i < this.hauteur; i++) { + + for (int j = 0; j < this.longueur; j++) { + //Affichage des murs de la carte + if(i==0 || i== this.hauteur -1 || j == 0 || j == this.longueur-1) { + carte[i][j] = "#"; + //generation de la sortie + if(i==sortie && j == this.longueur -1) { + carte[i][j] = "s"; + } + } else if(contains(wall, j) ) { + carte[i][j] = "#"; + + //trouver l'index du mur afin de pouvoir positionner la porte + for(int ii=0; ii