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

avancée sur la base de donnée des attaques et discours

This commit is contained in:
Fastium 2022-06-08 23:30:15 +02:00
parent 1a84524e14
commit aaeb151c43
14 changed files with 226 additions and 28 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;
@ -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
}

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

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

View File

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

View File

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

View File

@ -21,6 +21,5 @@ public class ScreenPlayer {
public void render(GdxGraphics g){
screenManager.render(g);
}
}

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

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

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

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 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 onKeyUp(int keycode) {
super.onKeyUp(keycode);
controller.keyStatus.put(keycode, false);
}
@Override
public void onKeyDown(int keycode) {
super.onKeyDown(keycode);
switch (keycode) {
default:
break;
}
controller.keyStatus.put(keycode, true);
}
}