From 2e034c4f858c4c2854a7372024417cf391fee007 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Heredero?= Date: Fri, 17 Jun 2022 21:45:05 +0200 Subject: [PATCH 1/5] select answer with row --- src/Control/Controller.java | 1 + src/Game/Battle.java | 4 +++- src/Main/PokeHES.java | 1 + src/Screen/ScreenBattle.java | 27 ++++++++++++++++++++------- src/Text/TextEnemy.java | 16 ++++++++++------ 5 files changed, 35 insertions(+), 14 deletions(-) diff --git a/src/Control/Controller.java b/src/Control/Controller.java index bf4a3fd..9303ebd 100644 --- a/src/Control/Controller.java +++ b/src/Control/Controller.java @@ -25,6 +25,7 @@ public class Controller { keyStatus.put(Input.Keys.NUM_3, false); keyStatus.put(Input.Keys.NUM_4, false); keyStatus.put(Input.Keys.SPACE, false); + keyStatus.put(Input.Keys.A, false); keyStatus.put(Input.Keys.ENTER, false); } diff --git a/src/Game/Battle.java b/src/Game/Battle.java index 0b8e8b9..6f3fe2a 100644 --- a/src/Game/Battle.java +++ b/src/Game/Battle.java @@ -18,12 +18,14 @@ public class Battle { public int xpPlayer; public boolean screenBattleOn = true; + public int cursor = 0; public Battle(Enemy e){ if(e != null){ textEnemy = new TextEnemy(e); - textEnemy.generateText(); + textEnemy.generateText(cursor); } + pvEnemy = e.getPv(); lineSpeech = 0; newXp = 0; diff --git a/src/Main/PokeHES.java b/src/Main/PokeHES.java index df9ce32..cc1ded2 100644 --- a/src/Main/PokeHES.java +++ b/src/Main/PokeHES.java @@ -46,6 +46,7 @@ public class PokeHES extends PortableApplication { sp.init(); controller.init(); + enemies.add(new Enemy("Mudry", 5, 6, "21RI", 700, "informatique")); // add player, create and add all enemies in entities entities.add((Entity) sp.p); enemies.add(new Enemy("Gloeckner", 1, 7, "21N307", 600, "allemand")); diff --git a/src/Screen/ScreenBattle.java b/src/Screen/ScreenBattle.java index c59dcea..eaaec7e 100644 --- a/src/Screen/ScreenBattle.java +++ b/src/Screen/ScreenBattle.java @@ -109,24 +109,37 @@ public class ScreenBattle extends RenderingScreen{ public void manage(Controller c, Battle battle){ //add a rising front to have one impulsion if(PokeHES.risingFront){ - //the enemi is attacking + //the enemy is attacking if( battle.getAttackOn() == false){ - if (c.keyStatus.get(Input.Keys.SPACE)){ + if (c.keyStatus.get(Input.Keys.SPACE) || c.keyStatus.get(Input.Keys.A)){ battle.action(-1); } } - //the enemi is speaking + + if (c.keyStatus.get(Input.Keys.DOWN)){ + b.cursor++; + } + else if (c.keyStatus.get(Input.Keys.UP)){ + b.cursor--; + } + + if (b.cursor>3)b.cursor =0; + if (b.cursor<0)b.cursor =3; + + System.out.println("" + b.cursor); + + //the enemy is speaking if(battle.getAttackOn() == true){ - if (c.keyStatus.get(Input.Keys.NUM_1)){ + if (c.keyStatus.get(Input.Keys.NUM_1) || c.keyStatus.get(Input.Keys.A) && b.cursor == 0){ battle.action(1); } - else if (c.keyStatus.get(Input.Keys.NUM_2)){ + else if (c.keyStatus.get(Input.Keys.NUM_2) || c.keyStatus.get(Input.Keys.A) && b.cursor == 1){ battle.action(2); } - else if (c.keyStatus.get(Input.Keys.NUM_3)){ + else if (c.keyStatus.get(Input.Keys.NUM_3) || c.keyStatus.get(Input.Keys.A) && b.cursor == 2){ battle.action(3); } - else if (c.keyStatus.get(Input.Keys.NUM_4)){ + else if (c.keyStatus.get(Input.Keys.NUM_4) || c.keyStatus.get(Input.Keys.A) && b.cursor == 3){ battle.action(4); } } diff --git a/src/Text/TextEnemy.java b/src/Text/TextEnemy.java index b990934..3d45edf 100644 --- a/src/Text/TextEnemy.java +++ b/src/Text/TextEnemy.java @@ -2,6 +2,7 @@ package Text; import Entity.Enemy; import java.util.Vector; +import java.text.Normalizer; import java.util.Arrays; import java.util.Random; @@ -66,7 +67,7 @@ public class TextEnemy { //generate the text who is displays in battle screen - public void generateText(){ + public void generateText(int cursor){ int i =1; //introduction line @@ -88,13 +89,16 @@ public class TextEnemy { } //Format the line + String[] row = new String[4]; + row[0] = row[1] = row[2] = row[3] = ""; + row[cursor] = "->"; String attack = formatLine(speechData.getSpeechs(i++) + fightData.getAttack(orderAttack[j]).attack + " ("+fightData.getAttack(orderAttack[j]).getXp()+ ") ", CUT); - String answer1 = formatLine("1. " + fightData.getAttack(orderAttack[j]).getAnswer(orderAnswer[0]) , CUT); - String answer2 = formatLine("2. " + fightData.getAttack(orderAttack[j]).getAnswer(orderAnswer[1]) , CUT); - String answer3 = formatLine("3. " + fightData.getAttack(orderAttack[j]).getAnswer(orderAnswer[2]) , CUT); - String answer4 = formatLine("4. " + fightData.getAttack(orderAttack[j]).getAnswer(orderAnswer[3]) , CUT); + String answer1 = formatLine(row[0] + " " + fightData.getAttack(orderAttack[j]).getAnswer(orderAnswer[0]) , CUT); + String answer2 = formatLine(row[1] + " " + fightData.getAttack(orderAttack[j]).getAnswer(orderAnswer[1]) , CUT); + String answer3 = formatLine(row[2] + " " + fightData.getAttack(orderAttack[j]).getAnswer(orderAnswer[2]) , CUT); + String answer4 = formatLine(row[3] + " " + fightData.getAttack(orderAttack[j]).getAnswer(orderAnswer[3]) , CUT); - //attack and answer (number on vector : 1-4) + //attack and answer (number on vector : 1-4) lines.add(new Line(attack + "\n" +answer1 + "\n" + answer2 + "\n" + answer3 + "\n" + answer4, true)); //save the order of the answer From c6b854948dc0d52813f99fbd1491b6814a0912ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Heredero?= Date: Sun, 19 Jun 2022 23:14:15 +0200 Subject: [PATCH 2/5] with row done --- src/Control/Keyboard.java | 4 ++++ src/Game/Battle.java | 12 ++++++------ src/Main/PokeHES.java | 9 ++++++--- src/Screen/ScreenBattle.java | 34 ++++++++++++++++++++-------------- src/Text/TextEnemy.java | 15 +++++++++++---- 5 files changed, 47 insertions(+), 27 deletions(-) diff --git a/src/Control/Keyboard.java b/src/Control/Keyboard.java index 5bdd215..a7dd09d 100644 --- a/src/Control/Keyboard.java +++ b/src/Control/Keyboard.java @@ -1,5 +1,7 @@ package Control; +import com.badlogic.gdx.Input; + import Screen.ScreenPlayer; /** @@ -10,9 +12,11 @@ import Screen.ScreenPlayer; */ public class Keyboard { public void keyDown(int keycode, ScreenPlayer sp, Controller c) { + if (keycode == Input.Keys.SPACE) c.keyStatus.put(Input.Keys.A, true); c.keyStatus.put(keycode, true); } public void onKeyUp(int keycode, ScreenPlayer sp, Controller c) { + if (keycode == Input.Keys.SPACE) c.keyStatus.put(Input.Keys.A, false); c.keyStatus.put(keycode, false); } } diff --git a/src/Game/Battle.java b/src/Game/Battle.java index 6f3fe2a..736df43 100644 --- a/src/Game/Battle.java +++ b/src/Game/Battle.java @@ -33,17 +33,13 @@ public class Battle { public void readNextLine(){ //change line - System.out.println(textEnemy.lines.size()); + //System.out.println(textEnemy.lines.size()); if(lineSpeech < 5){ lineSpeech++; } - } public void action(int answer){ - System.out.println("pv enemy : " +pvEnemy); - System.out.println("xp player : " + xpPlayer); - System.out.println("xp win " + newXp); //the player is at the last question, the finish text must be displayed if(getLineSpeech() == 4){ @@ -98,10 +94,10 @@ public class Battle { public void updatePlayerEnemy(int xp){ //add xp for the player xpPlayer += xp; + if(xpPlayer>6000) xpPlayer = 6000; //remove pv enemy pvEnemy -= xp; if(pvEnemy<0) pvEnemy =0; - } public void finishSpeech(){ @@ -158,4 +154,8 @@ public class Battle { public void setPlayer(Player p){ this.player = p; } + + public void updateText(){ + if(e != null) textEnemy.generateText(cursor); + } } diff --git a/src/Main/PokeHES.java b/src/Main/PokeHES.java index 5395532..3e583e5 100644 --- a/src/Main/PokeHES.java +++ b/src/Main/PokeHES.java @@ -2,6 +2,8 @@ package Main; import java.util.Vector; +import com.badlogic.gdx.Input; + import Control.Controller; import Entity.Enemy; import Entity.Entity; @@ -21,7 +23,6 @@ public class PokeHES extends PortableApplication { private static Vector entities = new Vector<>(); private long beginTime; private long lastMesure; - private long stairTime; public static boolean risingFront = false; @@ -146,14 +147,16 @@ public class PokeHES extends PortableApplication { public void onKeyDown(int keycode) { super.onKeyDown(keycode); risingFront = true; + if (keycode == Input.Keys.SPACE) controller.keyStatus.put(Input.Keys.A, true); + if (keycode == Input.Keys.ENTER) controller.keyStatus.put(Input.Keys.A, true); controller.keyStatus.put(keycode, true); - sp.screenManager.getActiveScreen().onKeyUp(keycode); } @Override public void onKeyUp(int keycode) { super.onKeyUp(keycode); risingFront = false; + if (keycode == Input.Keys.SPACE) controller.keyStatus.put(Input.Keys.A, false); + if (keycode == Input.Keys.ENTER) controller.keyStatus.put(Input.Keys.A, false); controller.keyStatus.put(keycode, false); - sp.screenManager.getActiveScreen().onKeyDown(keycode); } } diff --git a/src/Screen/ScreenBattle.java b/src/Screen/ScreenBattle.java index ac10044..9e1cf80 100644 --- a/src/Screen/ScreenBattle.java +++ b/src/Screen/ScreenBattle.java @@ -28,7 +28,7 @@ public class ScreenBattle extends RenderingScreen{ private BitmapImage enemyImg; private BitmapImage playerImg; - private Battle b = null; + public Battle b = null; @Override @@ -109,40 +109,46 @@ public class ScreenBattle extends RenderingScreen{ public void manage(Controller c, Battle battle){ //add a rising front to have one impulsion if(PokeHES.risingFront){ + + if (c.keyStatus.get(Input.Keys.DOWN)){ + battle.cursor++; + } + else if (c.keyStatus.get(Input.Keys.UP)){ + battle.cursor--; + } + + if (battle.cursor > 3) battle.cursor = 0; + if (battle.cursor < 0) battle.cursor = 3; + //the enemy is attacking if( battle.getAttackOn() == false){ if (c.keyStatus.get(Input.Keys.SPACE) || c.keyStatus.get(Input.Keys.A)){ battle.action(-1); } } - - if (c.keyStatus.get(Input.Keys.DOWN)){ - b.cursor++; - } - else if (c.keyStatus.get(Input.Keys.UP)){ - b.cursor--; - } - - if (b.cursor>3)b.cursor =0; - if (b.cursor<0)b.cursor =3; - - System.out.println("" + b.cursor); - + //the enemy is speaking if(battle.getAttackOn() == true){ if (c.keyStatus.get(Input.Keys.NUM_1) || c.keyStatus.get(Input.Keys.A) && b.cursor == 0){ battle.action(1); + battle.cursor = 0; } else if (c.keyStatus.get(Input.Keys.NUM_2) || c.keyStatus.get(Input.Keys.A) && b.cursor == 1){ battle.action(2); + battle.cursor = 0; } else if (c.keyStatus.get(Input.Keys.NUM_3) || c.keyStatus.get(Input.Keys.A) && b.cursor == 2){ battle.action(3); + battle.cursor = 0; } else if (c.keyStatus.get(Input.Keys.NUM_4) || c.keyStatus.get(Input.Keys.A) && b.cursor == 3){ battle.action(4); + battle.cursor = 0; } } + + b.updateText(); + //mettre le front à false jusqu'à ce que le bouton soit relâché PokeHES.risingFront = false; } diff --git a/src/Text/TextEnemy.java b/src/Text/TextEnemy.java index 3d45edf..f6227b8 100644 --- a/src/Text/TextEnemy.java +++ b/src/Text/TextEnemy.java @@ -2,7 +2,6 @@ package Text; import Entity.Enemy; import java.util.Vector; -import java.text.Normalizer; import java.util.Arrays; import java.util.Random; @@ -30,6 +29,11 @@ public class TextEnemy { //save random data (attack and answer) : attack, answer 1, answer 2 answer 3, answer 4 currentData = new Vector(); + orderAttack = randomGenerate(0, fightData.nbr_line-1, 4); + + //generate a random array to determine the order of the answer + orderAnswer = randomGenerate(0, 3, 4); + } public static int[] randomGenerate( int min, int max, int nbrRandom){ @@ -68,20 +72,21 @@ public class TextEnemy { //generate the text who is displays in battle screen public void generateText(int cursor){ + lines.clear(); int i =1; //introduction line String introduction = formatLine(speechData.getSpeechs(0), CUT); lines.add(new Line(introduction, false)); - orderAttack = randomGenerate(0, fightData.nbr_line-1, 4); + //orderAttack = randomGenerate(0, fightData.nbr_line-1, 4); for(int j=0; j<4;j++){ int[] currentRandom = new int[5]; currentRandom[0] = orderAttack[j]; //generate a random array to determine the order of the answer - orderAnswer = randomGenerate(0, 3, 4); + //orderAnswer = randomGenerate(0, 3, 4); //save the order of answer and attack for(int k=1;k<5;k++){ @@ -90,7 +95,7 @@ public class TextEnemy { //Format the line String[] row = new String[4]; - row[0] = row[1] = row[2] = row[3] = ""; + row[0] = row[1] = row[2] = row[3] = " "; row[cursor] = "->"; String attack = formatLine(speechData.getSpeechs(i++) + fightData.getAttack(orderAttack[j]).attack + " ("+fightData.getAttack(orderAttack[j]).getXp()+ ") ", CUT); String answer1 = formatLine(row[0] + " " + fightData.getAttack(orderAttack[j]).getAnswer(orderAnswer[0]) , CUT); @@ -106,9 +111,11 @@ public class TextEnemy { } //display answer + /* for(int[] a : currentData){ System.out.println(Arrays.toString(a)); } + */ //finish (win and death) From c94e170a305f71cf8513be6f92e162a3eda22ff7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Heredero?= Date: Sun, 19 Jun 2022 23:29:02 +0200 Subject: [PATCH 3/5] add version --- src/Entity/Enemy.java | 5 +++++ src/Entity/Player.java | 5 +++++ src/Entity/Stuff.java | 5 +++++ src/Game/Battle.java | 5 +++++ src/Main/PokeHES.java | 6 +++++- src/Main/Settings.java | 5 +++++ src/Screen/ManagerOfScreen.java | 5 +++++ src/Screen/ScreenBattle.java | 5 +++++ src/Screen/ScreenEnd.java | 13 +++++++++---- src/Screen/ScreenMap.java | 5 +++++ src/Screen/ScreenPlayer.java | 5 +++++ src/Text/Attack.java | 5 +++++ src/Text/FightData.java | 5 +++++ src/Text/Line.java | 5 +++++ src/Text/SpeechData.java | 5 +++++ src/Text/TextEnemy.java | 10 +++++++--- 16 files changed, 86 insertions(+), 8 deletions(-) diff --git a/src/Entity/Enemy.java b/src/Entity/Enemy.java index 9ad00ae..f6756d3 100644 --- a/src/Entity/Enemy.java +++ b/src/Entity/Enemy.java @@ -4,6 +4,11 @@ import com.badlogic.gdx.math.Vector2; import Main.Settings; +/** + * @author Rémi Heredero + * @author Yann Sierro + * @version 1.0.0 + */ public class Enemy extends Character{ private String subject; diff --git a/src/Entity/Player.java b/src/Entity/Player.java index 9cce05b..15a4ec3 100644 --- a/src/Entity/Player.java +++ b/src/Entity/Player.java @@ -11,6 +11,11 @@ import Main.PokeHES; import Main.Settings; import Screen.ScreenMap; +/** + * @author Rémi Heredero + * @author Yann Sierro + * @version 1.0.0 + */ public class Player extends Character{ private int xp = 0; diff --git a/src/Entity/Stuff.java b/src/Entity/Stuff.java index 6562e43..1d4f60b 100644 --- a/src/Entity/Stuff.java +++ b/src/Entity/Stuff.java @@ -2,6 +2,11 @@ package Entity; import ch.hevs.gdx2d.lib.GdxGraphics; +/** + * @author Rémi Heredero + * @author Yann Sierro + * @version 1.0.0 + */ public class Stuff extends Entity{ public Stuff(String name, int x, int y, String map) { diff --git a/src/Game/Battle.java b/src/Game/Battle.java index 736df43..913731c 100644 --- a/src/Game/Battle.java +++ b/src/Game/Battle.java @@ -4,6 +4,11 @@ import Entity.Enemy; import Entity.Player; import Text.TextEnemy; +/** + * @author Rémi Heredero + * @author Yann Sierro + * @version 1.0.2 + */ public class Battle { public Enemy e; diff --git a/src/Main/PokeHES.java b/src/Main/PokeHES.java index 3e583e5..e79904e 100644 --- a/src/Main/PokeHES.java +++ b/src/Main/PokeHES.java @@ -15,6 +15,11 @@ import Screen.ScreenPlayer; import ch.hevs.gdx2d.desktop.PortableApplication; import ch.hevs.gdx2d.lib.GdxGraphics; +/** + * @author Rémi Heredero + * @author Yann Sierro + * @version 1.0.2 + */ public class PokeHES extends PortableApplication { private ScreenPlayer sp; @@ -48,7 +53,6 @@ public class PokeHES extends PortableApplication { sp.init(); controller.init(); - enemies.add(new Enemy("Mudry", 5, 6, "21RI", 700, "informatique")); // add player, create and add all enemies in entities entities.add((Entity) sp.p); enemies.add(new Enemy("gloeckner", 1, 7, "21N307", 600, "allemand")); diff --git a/src/Main/Settings.java b/src/Main/Settings.java index 75e5b30..c263d00 100644 --- a/src/Main/Settings.java +++ b/src/Main/Settings.java @@ -1,5 +1,10 @@ package Main; +/** + * @author Rémi Heredero + * @author Yann Sierro + * @version 1.0.0 + */ public class Settings { public static final boolean ANDROID = false; diff --git a/src/Screen/ManagerOfScreen.java b/src/Screen/ManagerOfScreen.java index dc4b3b5..614c8af 100644 --- a/src/Screen/ManagerOfScreen.java +++ b/src/Screen/ManagerOfScreen.java @@ -2,6 +2,11 @@ package Screen; import ch.hevs.gdx2d.lib.ScreenManager; +/** + * @author Rémi Heredero + * @author Yann Sierro + * @version 1.0.0 + */ public class ManagerOfScreen extends ScreenManager{ ManagerOfScreen(){ } diff --git a/src/Screen/ScreenBattle.java b/src/Screen/ScreenBattle.java index 9e1cf80..5f193cd 100644 --- a/src/Screen/ScreenBattle.java +++ b/src/Screen/ScreenBattle.java @@ -17,6 +17,11 @@ import ch.hevs.gdx2d.components.bitmaps.BitmapImage; import ch.hevs.gdx2d.components.screen_management.RenderingScreen; import ch.hevs.gdx2d.lib.GdxGraphics; +/** + * @author Rémi Heredero + * @author Yann Sierro + * @version 1.0.2 + */ public class ScreenBattle extends RenderingScreen{ private static int EDGE = 10; diff --git a/src/Screen/ScreenEnd.java b/src/Screen/ScreenEnd.java index 761321e..0b3c13f 100644 --- a/src/Screen/ScreenEnd.java +++ b/src/Screen/ScreenEnd.java @@ -12,15 +12,20 @@ import Main.Settings; import ch.hevs.gdx2d.components.screen_management.RenderingScreen; import ch.hevs.gdx2d.lib.GdxGraphics; +/** + * @author Rémi Heredero + * @author Yann Sierro + * @version 1.0.0 + */ public class ScreenEnd extends RenderingScreen{ private String textEnd = null; - private BitmapFont unbuntuRegularWhite; + private BitmapFont ubuntuRegularWhite; @Override public void onInit() { //generate a new font - unbuntuRegularWhite = generateFont("font/Ubuntu-Regular.ttf", 30, Color.WHITE); + ubuntuRegularWhite = generateFont("font/Ubuntu-Regular.ttf", 30, Color.WHITE); } @@ -30,13 +35,13 @@ public class ScreenEnd extends RenderingScreen{ g.clear(Color.BLACK); //display the text - if(textEnd != null) g.drawStringCentered(Settings.SIDE/2, textEnd, unbuntuRegularWhite); + if(textEnd != null) g.drawStringCentered(Settings.SIDE/2, textEnd, ubuntuRegularWhite); } @Override public void dispose() { - unbuntuRegularWhite.dispose(); + ubuntuRegularWhite.dispose(); } //set a different text if the player win or loose diff --git a/src/Screen/ScreenMap.java b/src/Screen/ScreenMap.java index 89a3033..ec27cad 100644 --- a/src/Screen/ScreenMap.java +++ b/src/Screen/ScreenMap.java @@ -21,6 +21,11 @@ import Entity.Player; import ch.hevs.gdx2d.components.screen_management.RenderingScreen; import ch.hevs.gdx2d.lib.GdxGraphics; +/** + * @author Rémi Heredero + * @author Yann Sierro + * @version 1.0.1 + */ public class ScreenMap extends RenderingScreen{ // tiles management diff --git a/src/Screen/ScreenPlayer.java b/src/Screen/ScreenPlayer.java index b5c6a05..f419a0f 100644 --- a/src/Screen/ScreenPlayer.java +++ b/src/Screen/ScreenPlayer.java @@ -5,6 +5,11 @@ import Entity.Player; import Game.Battle; import ch.hevs.gdx2d.lib.GdxGraphics; +/** + * @author Rémi Heredero + * @author Yann Sierro + * @version 1.0.0 + */ public class ScreenPlayer { public ManagerOfScreen screenManager = new ManagerOfScreen(); public Player p = null; diff --git a/src/Text/Attack.java b/src/Text/Attack.java index 9835acf..30f02d2 100644 --- a/src/Text/Attack.java +++ b/src/Text/Attack.java @@ -1,5 +1,10 @@ package Text; +/** + * @author Rémi Heredero + * @author Yann Sierro + * @version 1.0.0 + */ public class Attack { String attack; int currentAttack; diff --git a/src/Text/FightData.java b/src/Text/FightData.java index ba7b3a7..aaa4147 100644 --- a/src/Text/FightData.java +++ b/src/Text/FightData.java @@ -6,6 +6,11 @@ import java.io.InputStreamReader; import java.nio.charset.StandardCharsets; import java.util.Vector; +/** + * @author Rémi Heredero + * @author Yann Sierro + * @version 1.0.0 + */ public class FightData { private Vector attacks = new Vector(); diff --git a/src/Text/Line.java b/src/Text/Line.java index 64df4ab..f6b2866 100644 --- a/src/Text/Line.java +++ b/src/Text/Line.java @@ -1,5 +1,10 @@ package Text; +/** + * @author Rémi Heredero + * @author Yann Sierro + * @version 1.0.0 + */ public class Line { public String line; public boolean attackOn; diff --git a/src/Text/SpeechData.java b/src/Text/SpeechData.java index ac20da6..b00267a 100644 --- a/src/Text/SpeechData.java +++ b/src/Text/SpeechData.java @@ -6,6 +6,11 @@ import java.io.InputStreamReader; import java.nio.charset.StandardCharsets; import java.util.Vector; +/** + * @author Rémi Heredero + * @author Yann Sierro + * @version 1.0.0 + */ public class SpeechData { Vector speechs = new Vector(); diff --git a/src/Text/TextEnemy.java b/src/Text/TextEnemy.java index f6227b8..85361bc 100644 --- a/src/Text/TextEnemy.java +++ b/src/Text/TextEnemy.java @@ -5,6 +5,11 @@ import java.util.Vector; import java.util.Arrays; import java.util.Random; +/** + * @author Rémi Heredero + * @author Yann Sierro + * @version 1.0.2 + */ public class TextEnemy { private static final int CUT = 55; public FightData fightData; @@ -73,6 +78,7 @@ public class TextEnemy { //generate the text who is displays in battle screen public void generateText(int cursor){ lines.clear(); + currentData.clear(); int i =1; //introduction line @@ -111,13 +117,11 @@ public class TextEnemy { } //display answer - /* + System.out.println("----------"); for(int[] a : currentData){ System.out.println(Arrays.toString(a)); } - */ - //finish (win and death) String dead = formatLine(speechData.getSpeechs(5),CUT); String alive = formatLine(speechData.getSpeechs(6), CUT); From 2fcec74e00f90c3dd74a165b0f30308b2193a25d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Heredero?= Date: Mon, 20 Jun 2022 09:35:29 +0200 Subject: [PATCH 4/5] fix random --- src/Game/Battle.java | 1 + src/Text/TextEnemy.java | 20 +++++++++++--------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/Game/Battle.java b/src/Game/Battle.java index 913731c..03b4f07 100644 --- a/src/Game/Battle.java +++ b/src/Game/Battle.java @@ -45,6 +45,7 @@ public class Battle { } public void action(int answer){ + textEnemy.randomAnswer(); //the player is at the last question, the finish text must be displayed if(getLineSpeech() == 4){ diff --git a/src/Text/TextEnemy.java b/src/Text/TextEnemy.java index 85361bc..eac4543 100644 --- a/src/Text/TextEnemy.java +++ b/src/Text/TextEnemy.java @@ -22,6 +22,8 @@ public class TextEnemy { private Vector currentData; + int[] currentRandom = new int[5]; + public TextEnemy(Enemy e){ //generate the vector of fight fightData = new FightData(e.getBranch()); @@ -36,9 +38,18 @@ public class TextEnemy { orderAttack = randomGenerate(0, fightData.nbr_line-1, 4); + randomAnswer(); + + } + + public void randomAnswer(){ //generate a random array to determine the order of the answer orderAnswer = randomGenerate(0, 3, 4); + //save the order of answer and attack + for(int k=1;k<5;k++){ + currentRandom[k] = orderAnswer[k-1]; + } } public static int[] randomGenerate( int min, int max, int nbrRandom){ @@ -88,17 +99,8 @@ public class TextEnemy { //orderAttack = randomGenerate(0, fightData.nbr_line-1, 4); for(int j=0; j<4;j++){ - int[] currentRandom = new int[5]; currentRandom[0] = orderAttack[j]; - //generate a random array to determine the order of the answer - //orderAnswer = randomGenerate(0, 3, 4); - - //save the order of answer and attack - for(int k=1;k<5;k++){ - currentRandom[k] = orderAnswer[k-1]; - } - //Format the line String[] row = new String[4]; row[0] = row[1] = row[2] = row[3] = " "; From 5d4aaa344df642a17355d33dbc820638792fa59b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Heredero?= Date: Mon, 20 Jun 2022 16:48:41 +0200 Subject: [PATCH 5/5] fix 4 attacks --- src/Screen/ScreenBattle.java | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/Screen/ScreenBattle.java b/src/Screen/ScreenBattle.java index 5f193cd..0e2c854 100644 --- a/src/Screen/ScreenBattle.java +++ b/src/Screen/ScreenBattle.java @@ -124,16 +124,13 @@ public class ScreenBattle extends RenderingScreen{ if (battle.cursor > 3) battle.cursor = 0; if (battle.cursor < 0) battle.cursor = 3; - - //the enemy is attacking - if( battle.getAttackOn() == false){ + + if( battle.getAttackOn() == false){ //the enemy is attacking if (c.keyStatus.get(Input.Keys.SPACE) || c.keyStatus.get(Input.Keys.A)){ battle.action(-1); + battle.cursor = 0; } - } - - //the enemy is speaking - if(battle.getAttackOn() == true){ + } else if(battle.getAttackOn() == true){ //the enemy is speaking if (c.keyStatus.get(Input.Keys.NUM_1) || c.keyStatus.get(Input.Keys.A) && b.cursor == 0){ battle.action(1); battle.cursor = 0; @@ -151,7 +148,7 @@ public class ScreenBattle extends RenderingScreen{ battle.cursor = 0; } } - + b.updateText(); //mettre le front à false jusqu'à ce que le bouton soit relâché