1
0
mirror of https://github.com/Klagarge/PokeHES.git synced 2024-11-26 19:13:27 +00:00

Merge pull request #9 from Klagarge:dialog

Dialog
This commit is contained in:
Rémi Heredero 2022-06-09 18:26:10 +02:00 committed by GitHub
commit a2ef0d2725
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 236 additions and 25 deletions

View File

@ -0,0 +1,7 @@
introduction text
attack 1
attack 2
attack 3
attack 4
death
win

View File

@ -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);
}
}

View File

@ -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
}

42
src/Main/PokeMudry.java Normal file
View File

@ -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);
}
}

11
src/Main/Settings.java Normal file
View File

@ -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;
}

View File

@ -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;

View File

@ -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);
}
@ -45,6 +60,24 @@ public class ScreenBattle extends RenderingScreen{
}
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();
}
}

View File

@ -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);
}

42
src/Text/SpeechData.java Normal file
View File

@ -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<String> speechs = new Vector<String>();
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);
}
}

52
src/Text/TextEnemy.java Normal file
View File

@ -0,0 +1,52 @@
package Text;
import java.util.Vector;
public class TextEnemy {
public FightData fightData;
public SpeechData speechData;
Vector<Line> line = new Vector<Line>();
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;
}
}

View File

@ -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,8 +15,9 @@ import ch.hevs.gdx2d.lib.ScreenManager;
public class testYann extends PortableApplication{
private ScreenManager s = new ScreenManager();
ScreenBattle b;
public Map<Integer, Boolean> keyStatus = new TreeMap<Integer, Boolean>();
double zoom;
Controller controller = new Controller();
public static void main(String[] args) {
new testYann();
@ -16,32 +25,37 @@ public class testYann extends PortableApplication{
}
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);
}
switch (keycode) {
default:
break;
}
controller.keyStatus.put(keycode, true);
}
}