1
0
mirror of https://github.com/Klagarge/PokeHES.git synced 2024-11-26 19:13:27 +00:00
This commit is contained in:
Fastium 2022-06-11 21:45:45 +02:00
parent f21a8c7482
commit d33945ccf4
4 changed files with 61 additions and 43 deletions

View File

@ -8,5 +8,7 @@ public class Battle {
* réponses juste * réponses juste
* barre de vie * barre de vie
*/ */
} }

View File

@ -21,6 +21,8 @@ public class PokeMudry extends PortableApplication {
private static Vector<Enemy> enemies = new Vector<>(); private static Vector<Enemy> enemies = new Vector<>();
private static Vector<Entity> entities = new Vector<>(); private static Vector<Entity> entities = new Vector<>();
public static boolean front_montant = false;
public static void main(String[] args) { public static void main(String[] args) {
new PokeMudry(); new PokeMudry();
@ -74,7 +76,7 @@ public class PokeMudry extends PortableApplication {
@Override @Override
public void onKeyDown(int keycode) { public void onKeyDown(int keycode) {
super.onKeyDown(keycode); super.onKeyDown(keycode);
front_montant = true;
switch (keycode) { switch (keycode) {
case Input.Keys.Z: case Input.Keys.Z:
if (sp.sm.zoom == 1.0) { if (sp.sm.zoom == 1.0) {
@ -93,6 +95,7 @@ public class PokeMudry extends PortableApplication {
@Override @Override
public void onKeyUp(int keycode) { public void onKeyUp(int keycode) {
super.onKeyUp(keycode); super.onKeyUp(keycode);
front_montant = false;
controller.keyStatus.put(keycode, false); controller.keyStatus.put(keycode, false);
sp.screenManager.getActiveScreen().onKeyDown(keycode); sp.screenManager.getActiveScreen().onKeyDown(keycode);
} }

View File

@ -10,14 +10,15 @@ import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.g2d.BitmapFont; import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator; import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator;
import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator.FreeTypeFontParameter; import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator.FreeTypeFontParameter;
import com.badlogic.gdx.scenes.scene2d.ui.Dialog;
import com.badlogic.gdx.utils.Align; import com.badlogic.gdx.utils.Align;
import Control.Controller; import Control.Controller;
import Entity.Enemy; import Entity.Enemy;
import Entity.Player; import Entity.Player;
import Game.Battle;
import Text.Line; import Text.Line;
import Text.TextEnemy; import Text.TextEnemy;
import Main.PokeMudry;
import Main.Settings; import Main.Settings;
public class ScreenBattle extends RenderingScreen{ public class ScreenBattle extends RenderingScreen{
@ -29,11 +30,14 @@ public class ScreenBattle extends RenderingScreen{
private BitmapFont optimus40; private BitmapFont optimus40;
private TextEnemy textEnemy; private Battle battle;
private int lineSpeech = 0;
private String lineDialog = "";
private int answer = 0; private TextEnemy textEnemy;
private static int lineSpeech = 0;
private static String lineDialog = "";
int i = 0;
private int answer = 0;
@ -44,30 +48,34 @@ public class ScreenBattle extends RenderingScreen{
textEnemy = new TextEnemy("enemi"); textEnemy = new TextEnemy("enemi");
textEnemy.generateText(); textEnemy.generateText();
//new battle game
battle = new Battle();
//display the question //display the question
generateFont("resources/font/OptimusPrinceps.ttf", 40, Color.BLACK); generateFont("resources/font/OptimusPrinceps.ttf", 40, Color.BLACK);
//initialize the first line //initialize the first line
readNextLine(); readNextLine();
System.out.println(1);
} }
@Override @Override
public void onGraphicRender(GdxGraphics g) { public void onGraphicRender(GdxGraphics g) {
g.clear(Color.BLACK); g.clear(Color.BLACK);
displayDialog(g); displayDialog(g);
} }
@Override @Override
public void dispose() { public void dispose() {
optimus40.dispose(); optimus40.dispose();
} }
public void generateFont(String file, int height, Color c ){ public void generateFont(String file, int height, Color c ){
@ -84,7 +92,7 @@ public class ScreenBattle extends RenderingScreen{
public void displayDialog(GdxGraphics g){ public void displayDialog(GdxGraphics g){
//dialog background //dialog background
g.drawFilledRectangle(Settings.SIDE/2, HEIGHT_DIALOG/2 + EDGE, 1600, HEIGHT_DIALOG, 0); g.drawFilledRectangle(Settings.SIDE/2, HEIGHT_DIALOG/2 + EDGE, WIDTH_DIALOG, HEIGHT_DIALOG, 0);
//dialog //dialog
g.drawString(15, 245 ,lineDialog , optimus40); g.drawString(15, 245 ,lineDialog , optimus40);
@ -93,7 +101,7 @@ public class ScreenBattle extends RenderingScreen{
public void displayEnemy(Enemy e){ public void displayEnemy(Enemy e){
// TODO affficher l'enemi // TODO affficher l'enemi
} }
public void displayPlayer(Player p){ public void displayPlayer(Player p){
//TODO afficher le joueur //TODO afficher le joueur
@ -106,41 +114,44 @@ public class ScreenBattle extends RenderingScreen{
} }
public void manage(Controller c){ public void manage(Controller c){
if (c.keyStatus.get(Input.Keys.SPACE)){ if(PokeMudry.front_montant){
if(textEnemy.lines.get(lineSpeech).attackOn == false){ if (c.keyStatus.get(Input.Keys.SPACE)){
readNextLine(); if(textEnemy.lines.get(lineSpeech).attackOn == false){
readNextLine();
} }
else if (c.keyStatus.get(Input.Keys.NUM_1)){
} if(textEnemy.lines.get(lineSpeech).attackOn == true){
if (c.keyStatus.get(Input.Keys.NUM_1)){ readNextLine();
if(textEnemy.lines.get(lineSpeech).attackOn == true){ answer = 1;
readNextLine(); }
answer = 1;
} }
} else if (c.keyStatus.get(Input.Keys.NUM_2)){
if (c.keyStatus.get(Input.Keys.NUM_2)){ if(textEnemy.lines.get(lineSpeech).attackOn == true){
if(textEnemy.lines.get(lineSpeech).attackOn == true){ readNextLine();
readNextLine(); answer = 2;
answer = 2; }
} }
} else if (c.keyStatus.get(Input.Keys.NUM_3)){
if (c.keyStatus.get(Input.Keys.NUM_3)){ if(textEnemy.lines.get(lineSpeech).attackOn == true){
if(textEnemy.lines.get(lineSpeech).attackOn == true){ readNextLine();
readNextLine(); answer = 3;
answer = 3; }
} }
} else if (c.keyStatus.get(Input.Keys.NUM_4)){
if (c.keyStatus.get(Input.Keys.NUM_4)){ if(textEnemy.lines.get(lineSpeech).attackOn == true){
if(textEnemy.lines.get(lineSpeech).attackOn == true){ readNextLine();
readNextLine(); answer = 4;
answer = 4; }
} }
//mettre le front à false jusqu'à ce que le bouton soit relâché
PokeMudry.front_montant = false;
} }
} }
}
} }

View File

@ -5,13 +5,14 @@ import java.util.TreeMap;
import Control.Controller; import Control.Controller;
import Entity.Enemy; import Entity.Enemy;
import Screen.ScreenBattle; import Screen.ScreenBattle;
import Screen.ScreenPlayer;
import ch.hevs.gdx2d.desktop.PortableApplication; import ch.hevs.gdx2d.desktop.PortableApplication;
import ch.hevs.gdx2d.lib.GdxGraphics; import ch.hevs.gdx2d.lib.GdxGraphics;
import ch.hevs.gdx2d.lib.ScreenManager; import ch.hevs.gdx2d.lib.ScreenManager;
public class testYann extends PortableApplication{ public class testYann extends PortableApplication{
private ScreenManager s = new ScreenManager(); ScreenPlayer sp = new ScreenPlayer();
public Map<Integer, Boolean> keyStatus = new TreeMap<Integer, Boolean>(); public Map<Integer, Boolean> keyStatus = new TreeMap<Integer, Boolean>();
double zoom; double zoom;
Controller controller = new Controller(); Controller controller = new Controller();
@ -28,15 +29,16 @@ public class testYann extends PortableApplication{
@Override @Override
public void onInit() { public void onInit() {
s.registerScreen(ScreenBattle.class);
Enemy e = new Enemy("enemi", 50, 50, "resources//lumberjack_sheet32.png", "desert"); Enemy e = new Enemy("enemi", 50, 50, "resources//lumberjack_sheet32.png", "desert");
} }
@Override @Override
public void onGraphicRender(GdxGraphics g) { public void onGraphicRender(GdxGraphics g) {
s.render(g);
sp.render(g);
sp.sb.manage(controller);
} }
@Override @Override