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 658c27e..b164f98 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; @@ -9,16 +9,18 @@ import ch.hevs.gdx2d.lib.GdxGraphics; public class Enemy extends Character{ private String map; - public FightData fightData; + public TextEnemy textEnemy; public Enemy(String name, int x, int y, String img, String map) { super(name, x, y, img); + //generate his text + this.textEnemy = new TextEnemy(name); + textEnemy.generateText(); this.map = map; turn(Character.Direction.DOWN); //generate the vector of fight fightData = new FightData(name); - //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 b9009a3..c7326df 100644 --- a/src/PokeMudry.java +++ b/src/PokeMudry.java @@ -16,6 +16,9 @@ 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 sp; private Controller controller; //private Player p1; diff --git a/src/Screen/ScreenBattle.java b/src/Screen/ScreenBattle.java index 647cd2e..3ee7029 100644 --- a/src/Screen/ScreenBattle.java +++ b/src/Screen/ScreenBattle.java @@ -1,30 +1,45 @@ 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 int numAttack =0; + + 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 +59,24 @@ public class ScreenBattle extends RenderingScreen{ generator.dispose(); } + + public void displayEnemy(Enemy e){ + // stock his speech + + //display the person + + } + + public void readNextLine(){ + //display the speech + + } + + public void manage(Controller c){ + if (c.keyStatus.get(Input.Keys.SPACE)){ + readNextLine(); + } + } 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..c370f29 --- /dev/null +++ b/src/Text/TextEnemy.java @@ -0,0 +1,52 @@ +package Text; + +import java.util.Vector; + +public class TextEnemy { + public FightData fightData; + public SpeechData speechData; + + 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(new Line(speechData.getSpeechs(i++), false)); + + for(int j=0; i<4;i++){ + //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, 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; + } +} 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); + } }