From aaeb151c43af80f097795d60367fe37822922552 Mon Sep 17 00:00:00 2001 From: Fastium <79766552+Fastium@users.noreply.github.com> Date: Wed, 8 Jun 2022 23:30:15 +0200 Subject: [PATCH 1/3] =?UTF-8?q?avanc=C3=A9e=20sur=20la=20base=20de=20donn?= =?UTF-8?q?=C3=A9e=20des=20attaques=20et=20discours?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- resources/{fight => Battle/Fight}/enemi.csv | 0 resources/Battle/Speech/enemi.txt | 7 +++ src/Control/Controller.java | 5 +++ src/Entity/Enemy.java | 9 ++-- src/Main/PokeMudry.java | 42 +++++++++++++++++ src/Main/Settings.java | 11 +++++ src/PokeMudry.java | 4 ++ src/Screen/ScreenBattle.java | 38 ++++++++++++++-- src/Screen/ScreenMap.java | 1 - src/Screen/ScreenPlayer.java | 1 - src/Text/FightData.java | 2 +- src/Text/SpeechData.java | 42 +++++++++++++++++ src/Text/TextEnemy.java | 42 +++++++++++++++++ src/testYann.java | 50 +++++++++++++-------- 14 files changed, 226 insertions(+), 28 deletions(-) rename resources/{fight => Battle/Fight}/enemi.csv (100%) create mode 100644 resources/Battle/Speech/enemi.txt create mode 100644 src/Main/PokeMudry.java create mode 100644 src/Main/Settings.java create mode 100644 src/Text/SpeechData.java create mode 100644 src/Text/TextEnemy.java diff --git a/resources/fight/enemi.csv b/resources/Battle/Fight/enemi.csv similarity index 100% rename from resources/fight/enemi.csv rename to resources/Battle/Fight/enemi.csv diff --git a/resources/Battle/Speech/enemi.txt b/resources/Battle/Speech/enemi.txt new file mode 100644 index 0000000..ffb0ac0 --- /dev/null +++ b/resources/Battle/Speech/enemi.txt @@ -0,0 +1,7 @@ +introduction text +attack 1 +attack 2 +attack 3 +attack 4 +death +win \ No newline at end of file diff --git a/src/Control/Controller.java b/src/Control/Controller.java index 5787cd4..079acf0 100644 --- a/src/Control/Controller.java +++ b/src/Control/Controller.java @@ -14,6 +14,11 @@ public class Controller { keyStatus.put(Input.Keys.DOWN, false); keyStatus.put(Input.Keys.LEFT, false); keyStatus.put(Input.Keys.RIGHT, false); + keyStatus.put(Input.Keys.NUM_1, false); + keyStatus.put(Input.Keys.NUM_2, false); + keyStatus.put(Input.Keys.NUM_3, false); + keyStatus.put(Input.Keys.NUM_4, false); + keyStatus.put(Input.Keys.SPACE, false); } } diff --git a/src/Entity/Enemy.java b/src/Entity/Enemy.java index bf8a4d7..4c53991 100644 --- a/src/Entity/Enemy.java +++ b/src/Entity/Enemy.java @@ -1,6 +1,6 @@ package Entity; -import Text.FightData; +import Text.TextEnemy; import com.badlogic.gdx.math.Vector2; @@ -8,12 +8,13 @@ import ch.hevs.gdx2d.lib.GdxGraphics; public class Enemy extends Character{ - public FightData fightData; + public TextEnemy textEnemy; public Enemy(String name, int x, int y, String img) { super(name, x, y, img); - //generate the vector of fight - fightData = new FightData(name); + //generate his text + this.textEnemy = new TextEnemy(name); + textEnemy.generateText(); //TODO Auto-generated constructor stub } diff --git a/src/Main/PokeMudry.java b/src/Main/PokeMudry.java new file mode 100644 index 0000000..269960f --- /dev/null +++ b/src/Main/PokeMudry.java @@ -0,0 +1,42 @@ +package Main; + +import Screen.ScreenPlayer; +import ch.hevs.gdx2d.desktop.PortableApplication; +import ch.hevs.gdx2d.lib.GdxGraphics; + +public class PokeMudry extends PortableApplication { + + private ScreenPlayer screenPlayer = new ScreenPlayer(); + + public static void main(String[] args) { + new PokeMudry(); + } + + PokeMudry(){ + super(Settings.SIDE, Settings.SIDE); + } + + + @Override + public void onInit() { + screenPlayer.init(); + } + + @Override + public void onGraphicRender(GdxGraphics g) { + screenPlayer.render(g); + } + + + //key gestion + @Override + public void onKeyDown(int keycode) { + screenPlayer.screenManager.getActiveScreen().onKeyDown(keycode); + super.onKeyDown(keycode); + } + @Override + public void onKeyUp(int keycode) { + screenPlayer.screenManager.getActiveScreen().onKeyUp(keycode); + super.onKeyUp(keycode); + } +} diff --git a/src/Main/Settings.java b/src/Main/Settings.java new file mode 100644 index 0000000..cd99584 --- /dev/null +++ b/src/Main/Settings.java @@ -0,0 +1,11 @@ +package Main; + +public class Settings { + + public final boolean ANDROID = false; + public final int PLAYERS = 1; + public static final int TIME = 10; // number of minutes for kill all enemy + + public static final int SIDE = 800; + +} diff --git a/src/PokeMudry.java b/src/PokeMudry.java index a777dca..27435dc 100644 --- a/src/PokeMudry.java +++ b/src/PokeMudry.java @@ -7,6 +7,10 @@ public class PokeMudry extends PortableApplication { public final int PLAYERS = 1; public static final int TIME = 10; // number of minutes for kill all enemy + public static final int HEIGHT = 800; + public static final int width = 800; + + private ScreenPlayer screenPlayer = new ScreenPlayer(); diff --git a/src/Screen/ScreenBattle.java b/src/Screen/ScreenBattle.java index 647cd2e..b23f5bb 100644 --- a/src/Screen/ScreenBattle.java +++ b/src/Screen/ScreenBattle.java @@ -1,30 +1,44 @@ package Screen; +import Main.Settings; + import ch.hevs.gdx2d.components.screen_management.RenderingScreen; import ch.hevs.gdx2d.lib.GdxGraphics; import com.badlogic.gdx.Gdx; +import com.badlogic.gdx.Input; import com.badlogic.gdx.files.FileHandle; 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 Control.Controller; +import Entity.Enemy; + 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 boolean attackOn; + + private BitmapFont optimus40; @Override public void onInit() { //display the question - generateFont("resources//font//OptimusPrinceps.ttf", optimus40, 100, Color.WHITE); + generateFont("resources//font//OptimusPrinceps.ttf", optimus40, 20, Color.BLACK); } @Override public void onGraphicRender(GdxGraphics g) { - g.clear(Color.GREEN); - g.drawStringCentered(g.getScreenHeight()/2, "question", optimus40); + g.clear(Color.BLACK); + g.drawStringCentered(g.getScreenHeight()/2, "attack", optimus40); + g.drawFilledRectangle(Settings.SIDE/2, HEIGHT_DIALOG/2 + EDGE, WIDTH_DIALOG, HEIGHT_DIALOG, 0); } @@ -44,6 +58,24 @@ public class ScreenBattle extends RenderingScreen{ generator.dispose(); } + + public void displayEnemy(Enemy e){ + if(e.textEnemy.attackOn){ + attackOn = true; + } + else() + } + + public void readNextLine(){ + + + } + + public void manage(Controller c){ + if (c.keyStatus.get(Input.Keys.SPACE)){ + readNextLine(); + } + } diff --git a/src/Screen/ScreenMap.java b/src/Screen/ScreenMap.java index 8012e55..8d34aac 100644 --- a/src/Screen/ScreenMap.java +++ b/src/Screen/ScreenMap.java @@ -16,7 +16,6 @@ import com.badlogic.gdx.maps.tiled.TmxMapLoader; import com.badlogic.gdx.maps.tiled.renderers.OrthogonalTiledMapRenderer; import com.badlogic.gdx.math.Vector2; -import Entity.Player; import ch.hevs.gdx2d.components.screen_management.RenderingScreen; import ch.hevs.gdx2d.lib.GdxGraphics; diff --git a/src/Screen/ScreenPlayer.java b/src/Screen/ScreenPlayer.java index ce5fde5..283a7d7 100644 --- a/src/Screen/ScreenPlayer.java +++ b/src/Screen/ScreenPlayer.java @@ -21,6 +21,5 @@ public class ScreenPlayer { public void render(GdxGraphics g){ screenManager.render(g); - } } diff --git a/src/Text/FightData.java b/src/Text/FightData.java index 7e87ca2..bb3089a 100644 --- a/src/Text/FightData.java +++ b/src/Text/FightData.java @@ -54,7 +54,7 @@ public class FightData { } //return the vector with one attak - public Attack getAttacks(int a){ + public Attack getAttack(int a){ return attacks.get(a); } diff --git a/src/Text/SpeechData.java b/src/Text/SpeechData.java new file mode 100644 index 0000000..88ec186 --- /dev/null +++ b/src/Text/SpeechData.java @@ -0,0 +1,42 @@ +package Text; + +import java.util.Vector; +import java.io.BufferedReader; +import java.io.File; +import java.io.FileReader; + +public class SpeechData { + + Vector speechs = new Vector(); + File file; + + + public SpeechData(String name){ + file = new File("resources//fight//" + name + ".csv"); + } + + public void readFile() { + String line = ""; + try { + FileReader f = new FileReader(file); + BufferedReader bf = new BufferedReader(f); + + line = bf.readLine(); + while(line != null){ + + Speechs.add(line); + + line = bf.readLine(); + } + + bf.close(); + + } catch (Exception e) { + e.printStackTrace(); + } + + } + public String getSpeechs(int i) { + return speechs.elementAt(i); + } +} diff --git a/src/Text/TextEnemy.java b/src/Text/TextEnemy.java new file mode 100644 index 0000000..2532472 --- /dev/null +++ b/src/Text/TextEnemy.java @@ -0,0 +1,42 @@ +package Text; + +import java.util.Vector; + +public class TextEnemy { + public FightData fightData; + public SpeechData speechData; + public boolean attackOn = false; + + Vector line = new Vector(); + + public TextEnemy(String name){ + //generate the vector of fight + fightData = new FightData(name); + fightData.readFile(); + + //generate the vector of Speechs + speechData = new SpeechData(name); + speechData.readFile(); + + } + + public void generateText(){ + int i =0; + //introduction line + line.add(speechData.getSpeechs(i++)); + + for(int j=0; i<4;i++){ + //attack and answer (number on vector : 1-4) + line.add( + speechData.getSpeechs(i++) + fightData.getAttack(j).attack + "? ("+fightData.getAttack(j).xp+ ") " + "\n" + + fightData.getAttack(j).answer1 + "\n" + + fightData.getAttack(j).answer2 + "\n" + + fightData.getAttack(j).answer3 + "\n" + + fightData.getAttack(j).answer4); + } + //finish (win and death) + + } + + +} diff --git a/src/testYann.java b/src/testYann.java index a99d05a..08c44b8 100644 --- a/src/testYann.java +++ b/src/testYann.java @@ -1,5 +1,13 @@ +import java.util.TreeMap; +import java.util.Map; + +import com.badlogic.gdx.Input; + +import Control.Controller; +import Entity.Enemy; import Screen.ScreenBattle; + import ch.hevs.gdx2d.desktop.PortableApplication; import ch.hevs.gdx2d.lib.GdxGraphics; import ch.hevs.gdx2d.lib.ScreenManager; @@ -7,41 +15,47 @@ import ch.hevs.gdx2d.lib.ScreenManager; public class testYann extends PortableApplication{ private ScreenManager s = new ScreenManager(); - - ScreenBattle b; - + public Map keyStatus = new TreeMap(); + double zoom; + Controller controller = new Controller(); + public static void main(String[] args) { new testYann(); } testYann(){ - super(1000, 800); + super(800, 800); } @Override public void onInit() { - b = new ScreenBattle(); - s.registerScreen(b.getClass()); + + s.registerScreen(ScreenBattle.class); + Enemy e = new Enemy("enemi", 50, 50, "resources//lumberjack_sheet32.png"); + } @Override public void onGraphicRender(GdxGraphics g) { s.render(g); - } - + @Override + public void onKeyUp(int keycode) { + super.onKeyUp(keycode); + + controller.keyStatus.put(keycode, false); + } @Override - public void onKeyDown(int keycode) { - // TODO Auto-generated method stub - super.onKeyDown(keycode); - } - @Override - public void onKeyUp(int keycode) { - // TODO Auto-generated method stub - super.onKeyUp(keycode); - } - + public void onKeyDown(int keycode) { + super.onKeyDown(keycode); + + switch (keycode) { + default: + break; + } + controller.keyStatus.put(keycode, true); + } } From 0fc97ac683faa89b107e15bfff26eda9218656dd Mon Sep 17 00:00:00 2001 From: Fastium Date: Thu, 9 Jun 2022 06:58:49 +0200 Subject: [PATCH 2/3] new vector to display speech --- src/Screen/ScreenBattle.java | 11 ++++++----- src/Text/TextEnemy.java | 24 +++++++++++++++++------- 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/src/Screen/ScreenBattle.java b/src/Screen/ScreenBattle.java index b23f5bb..3ee7029 100644 --- a/src/Screen/ScreenBattle.java +++ b/src/Screen/ScreenBattle.java @@ -22,6 +22,7 @@ public class ScreenBattle extends RenderingScreen{ private static int WIDTH_DIALOG = Settings.SIDE - 2*EDGE; private boolean attackOn; + private int numAttack =0; private BitmapFont optimus40; @@ -60,14 +61,14 @@ public class ScreenBattle extends RenderingScreen{ } public void displayEnemy(Enemy e){ - if(e.textEnemy.attackOn){ - attackOn = true; - } - else() + // stock his speech + + //display the person + } public void readNextLine(){ - + //display the speech } diff --git a/src/Text/TextEnemy.java b/src/Text/TextEnemy.java index 2532472..c370f29 100644 --- a/src/Text/TextEnemy.java +++ b/src/Text/TextEnemy.java @@ -5,9 +5,8 @@ import java.util.Vector; public class TextEnemy { public FightData fightData; public SpeechData speechData; - public boolean attackOn = false; - Vector line = new Vector(); + Vector line = new Vector(); public TextEnemy(String name){ //generate the vector of fight @@ -23,20 +22,31 @@ public class TextEnemy { public void generateText(){ int i =0; //introduction line - line.add(speechData.getSpeechs(i++)); + line.add(new Line(speechData.getSpeechs(i++), false)); for(int j=0; i<4;i++){ - //attack and answer (number on vector : 1-4) - line.add( + //attack and answer (number on vector : 1-4) + line.add(new Line( speechData.getSpeechs(i++) + fightData.getAttack(j).attack + "? ("+fightData.getAttack(j).xp+ ") " + "\n" + fightData.getAttack(j).answer1 + "\n" + fightData.getAttack(j).answer2 + "\n" + fightData.getAttack(j).answer3 + "\n" + - fightData.getAttack(j).answer4); + fightData.getAttack(j).answer4, true )); + // TODO mélanger les attaques aléatoirement } //finish (win and death) - + line.add(new Line(speechData.getSpeechs(i++), false)); + line.add(new Line(speechData.getSpeechs(i++), false)); } } +class Line { + String line; + boolean attackOn; + + Line( String line, boolean attackOn){ + this.line = line; + this.attackOn = attackOn; + } +} From 33be740b3dd0680fb164b4aaac6d95d18dfc51e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Heredero?= Date: Thu, 9 Jun 2022 18:24:25 +0200 Subject: [PATCH 3/3] small change --- src/Screen/ScreenMap.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Screen/ScreenMap.java b/src/Screen/ScreenMap.java index e4d84ea..9a109db 100644 --- a/src/Screen/ScreenMap.java +++ b/src/Screen/ScreenMap.java @@ -16,6 +16,7 @@ import com.badlogic.gdx.maps.tiled.TmxMapLoader; import com.badlogic.gdx.maps.tiled.renderers.OrthogonalTiledMapRenderer; import com.badlogic.gdx.math.Vector2; +import Entity.Player; import ch.hevs.gdx2d.components.screen_management.RenderingScreen; import ch.hevs.gdx2d.lib.GdxGraphics;