From ba0f36625ec18fe739bb54cd013d3a81c105d550 Mon Sep 17 00:00:00 2001 From: Fastium Date: Sat, 11 Jun 2022 19:18:10 +0200 Subject: [PATCH 1/5] a --- src/Main/PokeMudry.java | 3 +-- src/Screen/ScreenBattle.java | 16 ++++++---------- src/Screen/ScreenPlayer.java | 2 +- 3 files changed, 8 insertions(+), 13 deletions(-) diff --git a/src/Main/PokeMudry.java b/src/Main/PokeMudry.java index 094fdbe..0ea5a6c 100644 --- a/src/Main/PokeMudry.java +++ b/src/Main/PokeMudry.java @@ -53,8 +53,8 @@ public class PokeMudry extends PortableApplication { public void onGraphicRender(GdxGraphics g) { g.clear(); sp.p.manageEntity(sp.sm, controller); + sp.sb.manage(controller); sp.render(g); - System.out.println(sp.screenManager.getActiveScreen().getClass()); //System.out.println(ScreenMap.class); for (Entity entity : entities) { @@ -64,7 +64,6 @@ public class PokeMudry extends PortableApplication { if (sp.p.frontOfEnemy && sp.screenManager.getActiveScreen().getClass().equals(ScreenMap.class)){ sp.e = sp.p.lastEnemy; - System.out.println("switch screen"); sp.screenManager.activateNextScreen(); g.resetCamera(); } diff --git a/src/Screen/ScreenBattle.java b/src/Screen/ScreenBattle.java index e2eb25b..7e52d76 100644 --- a/src/Screen/ScreenBattle.java +++ b/src/Screen/ScreenBattle.java @@ -25,10 +25,6 @@ public class ScreenBattle extends RenderingScreen{ private static int EDGE = 10; private static int HEIGHT_DIALOG = Settings.SIDE / 3; private static int WIDTH_DIALOG = Settings.SIDE - 2*EDGE; - private Enemy e; - - private boolean attackOn; - private int numAttack =0; private BitmapFont optimus40; @@ -62,6 +58,8 @@ public class ScreenBattle extends RenderingScreen{ displayDialog(g); + System.out.println(textEnemy.lines.get(lineSpeech).attackOn); + } @@ -92,16 +90,13 @@ public class ScreenBattle extends RenderingScreen{ g.drawString(15, 245 ,lineDialog , optimus40); } - public void setEnemy(Enemy e) { - this.e = e; - } public void displayEnemy(Enemy e){ - // stock his speech + // TODO affficher l'enemi } public void displayPlayer(Player p){ - //TODO afficher le joueur + //TODO afficher le joueur } public void readNextLine(){ @@ -113,6 +108,7 @@ public class ScreenBattle extends RenderingScreen{ public void manage(Controller c){ if (c.keyStatus.get(Input.Keys.SPACE)){ + if(textEnemy.lines.get(lineSpeech).attackOn == false){ readNextLine(); } @@ -136,7 +132,7 @@ public class ScreenBattle extends RenderingScreen{ } } if (c.keyStatus.get(Input.Keys.NUM_4)){ - if(textEnemy.lines.get(lineSpeech).attackOn == false){ + if(textEnemy.lines.get(lineSpeech).attackOn == true){ readNextLine(); answer = 4; } diff --git a/src/Screen/ScreenPlayer.java b/src/Screen/ScreenPlayer.java index a445491..7fb0dae 100644 --- a/src/Screen/ScreenPlayer.java +++ b/src/Screen/ScreenPlayer.java @@ -20,7 +20,7 @@ public class ScreenPlayer { } public void render(GdxGraphics g){ - sb.setEnemy(e); + sb.displayEnemy(e); sm.setPlayer(p); screenManager.render(g); } From f21a8c7482795d459ce94b48f75fa5c00892a1ba Mon Sep 17 00:00:00 2001 From: Fastium <79766552+Fastium@users.noreply.github.com> Date: Sat, 11 Jun 2022 19:32:43 +0200 Subject: [PATCH 2/5] Update ScreenBattle.java --- src/Screen/ScreenBattle.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Screen/ScreenBattle.java b/src/Screen/ScreenBattle.java index 7e52d76..b90f597 100644 --- a/src/Screen/ScreenBattle.java +++ b/src/Screen/ScreenBattle.java @@ -44,6 +44,9 @@ public class ScreenBattle extends RenderingScreen{ textEnemy = new TextEnemy("enemi"); textEnemy.generateText(); + + + //display the question generateFont("resources/font/OptimusPrinceps.ttf", 40, Color.BLACK); @@ -58,9 +61,6 @@ public class ScreenBattle extends RenderingScreen{ displayDialog(g); - System.out.println(textEnemy.lines.get(lineSpeech).attackOn); - - } @Override @@ -108,10 +108,10 @@ public class ScreenBattle extends RenderingScreen{ public void manage(Controller c){ if (c.keyStatus.get(Input.Keys.SPACE)){ - if(textEnemy.lines.get(lineSpeech).attackOn == false){ readNextLine(); } + } if (c.keyStatus.get(Input.Keys.NUM_1)){ if(textEnemy.lines.get(lineSpeech).attackOn == true){ From d33945ccf405f3e2e817c7901155d7ca3f749d64 Mon Sep 17 00:00:00 2001 From: Fastium <79766552+Fastium@users.noreply.github.com> Date: Sat, 11 Jun 2022 21:45:45 +0200 Subject: [PATCH 3/5] b --- src/Game/Battle.java | 2 + src/Main/PokeMudry.java | 5 ++- src/Screen/ScreenBattle.java | 87 ++++++++++++++++++++---------------- src/testYann.java | 10 +++-- 4 files changed, 61 insertions(+), 43 deletions(-) diff --git a/src/Game/Battle.java b/src/Game/Battle.java index c71fb08..b70f493 100644 --- a/src/Game/Battle.java +++ b/src/Game/Battle.java @@ -8,5 +8,7 @@ public class Battle { * réponses juste * barre de vie */ + + } diff --git a/src/Main/PokeMudry.java b/src/Main/PokeMudry.java index 0ea5a6c..55833c5 100644 --- a/src/Main/PokeMudry.java +++ b/src/Main/PokeMudry.java @@ -21,6 +21,8 @@ public class PokeMudry extends PortableApplication { private static Vector enemies = new Vector<>(); private static Vector entities = new Vector<>(); + public static boolean front_montant = false; + public static void main(String[] args) { new PokeMudry(); @@ -74,7 +76,7 @@ public class PokeMudry extends PortableApplication { @Override public void onKeyDown(int keycode) { super.onKeyDown(keycode); - + front_montant = true; switch (keycode) { case Input.Keys.Z: if (sp.sm.zoom == 1.0) { @@ -93,6 +95,7 @@ public class PokeMudry extends PortableApplication { @Override public void onKeyUp(int keycode) { super.onKeyUp(keycode); + front_montant = false; controller.keyStatus.put(keycode, false); sp.screenManager.getActiveScreen().onKeyDown(keycode); } diff --git a/src/Screen/ScreenBattle.java b/src/Screen/ScreenBattle.java index b90f597..d98fa5b 100644 --- a/src/Screen/ScreenBattle.java +++ b/src/Screen/ScreenBattle.java @@ -10,14 +10,15 @@ import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.graphics.g2d.BitmapFont; import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator; import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator.FreeTypeFontParameter; -import com.badlogic.gdx.scenes.scene2d.ui.Dialog; import com.badlogic.gdx.utils.Align; import Control.Controller; import Entity.Enemy; import Entity.Player; +import Game.Battle; import Text.Line; import Text.TextEnemy; +import Main.PokeMudry; import Main.Settings; public class ScreenBattle extends RenderingScreen{ @@ -29,11 +30,14 @@ public class ScreenBattle extends RenderingScreen{ private BitmapFont optimus40; - private TextEnemy textEnemy; - private int lineSpeech = 0; - private String lineDialog = ""; + private Battle battle; - private int answer = 0; + private TextEnemy textEnemy; + private static int lineSpeech = 0; + private static String lineDialog = ""; + int i = 0; + + private int answer = 0; @@ -44,30 +48,34 @@ public class ScreenBattle extends RenderingScreen{ textEnemy = new TextEnemy("enemi"); textEnemy.generateText(); - - + //new battle game + battle = new Battle(); + //display the question generateFont("resources/font/OptimusPrinceps.ttf", 40, Color.BLACK); //initialize the first line readNextLine(); + System.out.println(1); } + @Override public void onGraphicRender(GdxGraphics g) { g.clear(Color.BLACK); displayDialog(g); + + + } @Override public void dispose() { - optimus40.dispose(); - } public void generateFont(String file, int height, Color c ){ @@ -84,7 +92,7 @@ public class ScreenBattle extends RenderingScreen{ public void displayDialog(GdxGraphics g){ //dialog background - g.drawFilledRectangle(Settings.SIDE/2, HEIGHT_DIALOG/2 + EDGE, 1600, HEIGHT_DIALOG, 0); + g.drawFilledRectangle(Settings.SIDE/2, HEIGHT_DIALOG/2 + EDGE, WIDTH_DIALOG, HEIGHT_DIALOG, 0); //dialog g.drawString(15, 245 ,lineDialog , optimus40); @@ -93,7 +101,7 @@ public class ScreenBattle extends RenderingScreen{ public void displayEnemy(Enemy e){ // TODO affficher l'enemi - } + } public void displayPlayer(Player p){ //TODO afficher le joueur @@ -106,41 +114,44 @@ public class ScreenBattle extends RenderingScreen{ } + public void manage(Controller c){ - if (c.keyStatus.get(Input.Keys.SPACE)){ - if(textEnemy.lines.get(lineSpeech).attackOn == false){ - readNextLine(); + if(PokeMudry.front_montant){ + if (c.keyStatus.get(Input.Keys.SPACE)){ + if(textEnemy.lines.get(lineSpeech).attackOn == false){ + readNextLine(); } - - } - if (c.keyStatus.get(Input.Keys.NUM_1)){ - if(textEnemy.lines.get(lineSpeech).attackOn == true){ - readNextLine(); - answer = 1; + else if (c.keyStatus.get(Input.Keys.NUM_1)){ + if(textEnemy.lines.get(lineSpeech).attackOn == true){ + readNextLine(); + answer = 1; + } } - } - if (c.keyStatus.get(Input.Keys.NUM_2)){ - if(textEnemy.lines.get(lineSpeech).attackOn == true){ - readNextLine(); - answer = 2; + else if (c.keyStatus.get(Input.Keys.NUM_2)){ + if(textEnemy.lines.get(lineSpeech).attackOn == true){ + readNextLine(); + answer = 2; + } } - } - if (c.keyStatus.get(Input.Keys.NUM_3)){ - if(textEnemy.lines.get(lineSpeech).attackOn == true){ - readNextLine(); - answer = 3; + else if (c.keyStatus.get(Input.Keys.NUM_3)){ + if(textEnemy.lines.get(lineSpeech).attackOn == true){ + readNextLine(); + answer = 3; + } } - } - if (c.keyStatus.get(Input.Keys.NUM_4)){ - if(textEnemy.lines.get(lineSpeech).attackOn == true){ - readNextLine(); - answer = 4; + else if (c.keyStatus.get(Input.Keys.NUM_4)){ + if(textEnemy.lines.get(lineSpeech).attackOn == true){ + readNextLine(); + answer = 4; + } } + + //mettre le front à false jusqu'à ce que le bouton soit relâché + PokeMudry.front_montant = false; } + } - - - + } } diff --git a/src/testYann.java b/src/testYann.java index 037fc91..72b4da4 100644 --- a/src/testYann.java +++ b/src/testYann.java @@ -5,13 +5,14 @@ import java.util.TreeMap; import Control.Controller; import Entity.Enemy; import Screen.ScreenBattle; +import Screen.ScreenPlayer; import ch.hevs.gdx2d.desktop.PortableApplication; import ch.hevs.gdx2d.lib.GdxGraphics; import ch.hevs.gdx2d.lib.ScreenManager; public class testYann extends PortableApplication{ - private ScreenManager s = new ScreenManager(); + ScreenPlayer sp = new ScreenPlayer(); public Map keyStatus = new TreeMap(); double zoom; Controller controller = new Controller(); @@ -28,15 +29,16 @@ public class testYann extends PortableApplication{ @Override public void onInit() { - s.registerScreen(ScreenBattle.class); + Enemy e = new Enemy("enemi", 50, 50, "resources//lumberjack_sheet32.png", "desert"); } @Override public void onGraphicRender(GdxGraphics g) { - s.render(g); - + + sp.render(g); + sp.sb.manage(controller); } @Override From c121320a04818a025e264299f5405f5358518874 Mon Sep 17 00:00:00 2001 From: Fastium Date: Sun, 12 Jun 2022 12:10:57 +0200 Subject: [PATCH 4/5] c --- src/Game/Battle.java | 38 ++++++++++++--- src/Main/PokeMudry.java | 3 +- src/Screen/ScreenBattle.java | 91 +++++++++++++++--------------------- src/Screen/ScreenPlayer.java | 2 +- src/Text/FightData.java | 14 ++++-- src/Text/TextEnemy.java | 48 +++++++++++++++++-- 6 files changed, 125 insertions(+), 71 deletions(-) diff --git a/src/Game/Battle.java b/src/Game/Battle.java index b70f493..cdad210 100644 --- a/src/Game/Battle.java +++ b/src/Game/Battle.java @@ -1,14 +1,40 @@ package Game; +import Entity.Enemy; +import Text.TextEnemy; + public class Battle { - //TODO faire la logique du combat :$ - /* - * les points - * réponses juste - * barre de vie - */ + private Enemy enemy; + TextEnemy textEnemy; + public int lineSpeech = 0; + + public int answer = 0; + private boolean c; + + public Battle(Enemy enemy){ + this.enemy = enemy; + textEnemy = new TextEnemy("enemi"); // should be enemy.name + textEnemy.generateText(); + + //initialize the first line + System.out.println("lll : "+ getLine()); + + } + + public void readNextLine(){ + //change line + lineSpeech++; + } + + public boolean getAttackOn(){ + return textEnemy.lines.get(lineSpeech).attackOn; + } + + public String getLine(){ + return textEnemy.lines.get(lineSpeech).line; + } } diff --git a/src/Main/PokeMudry.java b/src/Main/PokeMudry.java index 55833c5..44d4271 100644 --- a/src/Main/PokeMudry.java +++ b/src/Main/PokeMudry.java @@ -4,6 +4,8 @@ package Main; import java.util.Vector; import java.util.Map.Entry; +import org.lwjgl.opencl.CLSampler; + import com.badlogic.gdx.Input; import Control.Controller; @@ -85,7 +87,6 @@ public class PokeMudry extends PortableApplication { sp.sm.zoom = 1; } return; - default: break; } diff --git a/src/Screen/ScreenBattle.java b/src/Screen/ScreenBattle.java index d98fa5b..6d489b1 100644 --- a/src/Screen/ScreenBattle.java +++ b/src/Screen/ScreenBattle.java @@ -32,33 +32,17 @@ public class ScreenBattle extends RenderingScreen{ private Battle battle; - private TextEnemy textEnemy; - private static int lineSpeech = 0; - private static String lineDialog = ""; - int i = 0; - - private int answer = 0; - - + private Enemy enemy; @Override public void onInit() { - - textEnemy = new TextEnemy("enemi"); - textEnemy.generateText(); - //new battle game - battle = new Battle(); - - + battle = new Battle(enemy); + //display the question generateFont("resources/font/OptimusPrinceps.ttf", 40, Color.BLACK); - - //initialize the first line - readNextLine(); - System.out.println(1); } @@ -68,9 +52,7 @@ public class ScreenBattle extends RenderingScreen{ displayDialog(g); - - - + System.out.println(battle.lineSpeech); } @Override @@ -95,8 +77,14 @@ public class ScreenBattle extends RenderingScreen{ g.drawFilledRectangle(Settings.SIDE/2, HEIGHT_DIALOG/2 + EDGE, WIDTH_DIALOG, HEIGHT_DIALOG, 0); //dialog - g.drawString(15, 245 ,lineDialog , optimus40); + g.drawString(15, 245 ,battle.getLine() , optimus40); + + + } + + public void setEnemy(Enemy enemy){ + this.enemy = enemy; } public void displayEnemy(Enemy e){ @@ -107,42 +95,37 @@ public class ScreenBattle extends RenderingScreen{ //TODO afficher le joueur } - public void readNextLine(){ - //display the speech and change line - lineDialog = textEnemy.lines.get(lineSpeech).line; - lineSpeech++; - - } - - public void manage(Controller c){ if(PokeMudry.front_montant){ - if (c.keyStatus.get(Input.Keys.SPACE)){ - if(textEnemy.lines.get(lineSpeech).attackOn == false){ - readNextLine(); - } - else if (c.keyStatus.get(Input.Keys.NUM_1)){ - if(textEnemy.lines.get(lineSpeech).attackOn == true){ - readNextLine(); - answer = 1; + System.out.println(battle.lineSpeech); + + + if( battle.getAttackOn() == false){ + if (c.keyStatus.get(Input.Keys.SPACE)){ + System.out.println("in"); + battle.readNextLine(); } } - else if (c.keyStatus.get(Input.Keys.NUM_2)){ - if(textEnemy.lines.get(lineSpeech).attackOn == true){ - readNextLine(); - answer = 2; + + + if(battle.getAttackOn() == true){ + if (c.keyStatus.get(Input.Keys.NUM_1)){ + System.out.println("je sui dansakjshfljkahflkasjhfdlkajshflkajshfdlkasjdhfalsdkjfh123412341234"); + battle.readNextLine(); + battle.answer = 1; } - } - else if (c.keyStatus.get(Input.Keys.NUM_3)){ - if(textEnemy.lines.get(lineSpeech).attackOn == true){ - readNextLine(); - answer = 3; + else if (c.keyStatus.get(Input.Keys.NUM_2)){ + battle.readNextLine(); + battle.answer = 2; } - } - else if (c.keyStatus.get(Input.Keys.NUM_4)){ - if(textEnemy.lines.get(lineSpeech).attackOn == true){ - readNextLine(); - answer = 4; + else if (c.keyStatus.get(Input.Keys.NUM_3)){ + battle.readNextLine(); + battle.answer = 3; + } + else if (c.keyStatus.get(Input.Keys.NUM_4)){ + battle.readNextLine(); + battle.answer = 4; + } } @@ -151,7 +134,7 @@ public class ScreenBattle extends RenderingScreen{ } - } + } } diff --git a/src/Screen/ScreenPlayer.java b/src/Screen/ScreenPlayer.java index 7fb0dae..a445491 100644 --- a/src/Screen/ScreenPlayer.java +++ b/src/Screen/ScreenPlayer.java @@ -20,7 +20,7 @@ public class ScreenPlayer { } public void render(GdxGraphics g){ - sb.displayEnemy(e); + sb.setEnemy(e); sm.setPlayer(p); screenManager.render(g); } diff --git a/src/Text/FightData.java b/src/Text/FightData.java index f5a9e5d..88f8b48 100644 --- a/src/Text/FightData.java +++ b/src/Text/FightData.java @@ -11,23 +11,33 @@ public class FightData { private File file; private static final String REGEX = ","; + public int nbre_line =0; + public FightData(String name) { file = new File("./resources/Battle/Fight/" + name + ".csv"); } + + public void readFile() { Attack attack; String line = ""; + try { FileReader f = new FileReader(file); BufferedReader bf = new BufferedReader(f); + + + //add the line in the vector attacks of attack line = bf.readLine(); while(line != null){ String[] a = line.split(REGEX);//change the regex if it is another attack = new Attack(a[0], a[1], a[2], a[3], a[4], Float.valueOf(a[5])); attacks.add(attack); line = bf.readLine(); + //add line + nbre_line++; } bf.close(); @@ -35,10 +45,6 @@ public class FightData { } catch (Exception e) { e.printStackTrace(); } - - - - } //return the vector with all attaks of one enemi diff --git a/src/Text/TextEnemy.java b/src/Text/TextEnemy.java index 3df83eb..1d6e313 100644 --- a/src/Text/TextEnemy.java +++ b/src/Text/TextEnemy.java @@ -1,6 +1,7 @@ package Text; import java.util.Vector; +import java.util.Random; public class TextEnemy { public FightData fightData; @@ -8,12 +9,18 @@ public class TextEnemy { public Vector lines = new Vector(); + public int[] orderAnswer; + public static void main(String[] args) { + TextEnemy t = new TextEnemy("enemi"); + t.generateText(); + for(Line l : t.lines) { System.out.println(l.line); } + } @@ -28,18 +35,49 @@ public class TextEnemy { } + int[] randomGenerate(int max_val){ + int min_val = 0; + int x; + int[] t = new int[max_val-1]; + Random ran = new Random(); + + int i=0; + + + while(i Date: Sun, 12 Jun 2022 14:26:02 +0200 Subject: [PATCH 5/5] d --- src/Game/Battle.java | 14 ++++- src/Screen/ScreenBattle.java | 4 +- src/Text/TextEnemy.java | 42 +++++++++----- src/testYann.java | 103 +++++++++++++++-------------------- 4 files changed, 87 insertions(+), 76 deletions(-) diff --git a/src/Game/Battle.java b/src/Game/Battle.java index cdad210..8dbfc6b 100644 --- a/src/Game/Battle.java +++ b/src/Game/Battle.java @@ -8,16 +8,19 @@ public class Battle { private Enemy enemy; TextEnemy textEnemy; - public int lineSpeech = 0; + private int lineSpeech; - public int answer = 0; - private boolean c; + public int answer; + public Battle(Enemy enemy){ this.enemy = enemy; textEnemy = new TextEnemy("enemi"); // should be enemy.name textEnemy.generateText(); + lineSpeech = 0; + answer = 0; + //initialize the first line System.out.println("lll : "+ getLine()); @@ -26,6 +29,7 @@ public class Battle { public void readNextLine(){ //change line lineSpeech++; + } public boolean getAttackOn(){ @@ -35,6 +39,10 @@ public class Battle { public String getLine(){ return textEnemy.lines.get(lineSpeech).line; } + + public int getLineSpeech() { + return lineSpeech; + } } diff --git a/src/Screen/ScreenBattle.java b/src/Screen/ScreenBattle.java index 6d489b1..9d8e94f 100644 --- a/src/Screen/ScreenBattle.java +++ b/src/Screen/ScreenBattle.java @@ -52,7 +52,7 @@ public class ScreenBattle extends RenderingScreen{ displayDialog(g); - System.out.println(battle.lineSpeech); + System.out.println("render: " + battle.getLineSpeech()); } @Override @@ -97,7 +97,7 @@ public class ScreenBattle extends RenderingScreen{ public void manage(Controller c){ if(PokeMudry.front_montant){ - System.out.println(battle.lineSpeech); + System.out.println("manage: " + battle.getLineSpeech()); if( battle.getAttackOn() == false){ diff --git a/src/Text/TextEnemy.java b/src/Text/TextEnemy.java index 1d6e313..53b0d52 100644 --- a/src/Text/TextEnemy.java +++ b/src/Text/TextEnemy.java @@ -35,26 +35,42 @@ public class TextEnemy { } - int[] randomGenerate(int max_val){ - int min_val = 0; + int[] randomGenerate(int max_val){ + int max = 8-1; + Random r = new Random(); + + int nbre = 4; + + int[] t = new int[nbre]; int x; - int[] t = new int[max_val-1]; - Random ran = new Random(); - int i=0; + boolean same = false; + // initialize array at -1 + for(int j=0; j keyStatus = new TreeMap(); - double zoom; - Controller controller = new Controller(); - + +class testYann{ public static void main(String[] args) { - new testYann(); + int max = 8-1; + Random r = new Random(); + + int nbre = 4; + + int[] a = new int[nbre]; + int x; + int i=0; + boolean same = false; + + for(int j=0; j