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

Merge pull request #18 from Klagarge:buf-fix

done
This commit is contained in:
Rémi Heredero 2022-06-12 16:37:10 +02:00 committed by GitHub
commit 49983d67c9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 41 additions and 24 deletions

View File

@ -10,6 +10,8 @@ import com.badlogic.gdx.Input;
import Control.Controller;
import Entity.Enemy;
import Entity.Entity;
import Game.Battle;
import Screen.ScreenBattle;
import Screen.ScreenMap;
import Screen.ScreenPlayer;
import ch.hevs.gdx2d.desktop.PortableApplication;
@ -57,28 +59,29 @@ public class PokeMudry extends PortableApplication {
@Override
public void onGraphicRender(GdxGraphics g) {
g.clear();
sp.p.manageEntity(sp.sm, controller);
sp.sb.manage(controller);
sp.render(g);
//System.out.println(ScreenMap.class);
boolean onMapScreen = sp.screenManager.getActiveScreen().getClass().equals(ScreenMap.class);
boolean onBattleScreen = sp.screenManager.getActiveScreen().getClass().equals(ScreenBattle.class);
if(onMapScreen) sp.p.manageEntity(sp.sm, controller);
sp.render(g);
for (Entity entity : entities) {
// Render only entities on the good map
if (entity.getMap().equals(sp.sm.map) && onMapScreen)
entity.graphicRender(g);
}
// Switch screen
if (sp.p.frontOfEnemy && onMapScreen){
sp.e = sp.p.lastEnemy;
sp.screenManager.activateNextScreen();
//sp.screenManager.activateNextScreen();
sp.sb = sp.screenManager.getScreenBattle();
sp.b = new Battle(sp.e);
g.resetCamera();
}
if(onBattleScreen) sp.sb.manage(controller, sp.b);
// Graphics render
sp.render(g);
for (Entity entity : entities) {
// Render only entities on the good map
if (entity.getMap().equals(sp.sm.map) && onMapScreen)
entity.graphicRender(g);
}
}

View File

@ -30,7 +30,7 @@ public class ScreenBattle extends RenderingScreen{
private BitmapFont optimus40;
private Battle battle;
private Battle b = null;
private Enemy enemy;
@ -38,7 +38,7 @@ public class ScreenBattle extends RenderingScreen{
@Override
public void onInit() {
//new battle game
battle = new Battle(enemy);
//battle = new Battle(enemy);
//display the question
generateFont("resources/font/OptimusPrinceps.ttf", 40, Color.BLACK);
@ -52,7 +52,7 @@ public class ScreenBattle extends RenderingScreen{
displayDialog(g);
System.out.println("render: " + battle.getLineSpeech());
//System.out.println("render: " + battle.getLineSpeech());
}
@Override
@ -60,7 +60,13 @@ public class ScreenBattle extends RenderingScreen{
optimus40.dispose();
}
public void setBattle(Battle battle) {
this.b = battle;
}
public void generateFont(String file, int height, Color c ){
//Generate font with the file .ttf
FileHandle fileHandle = Gdx.files.internal(file);
FreeTypeFontParameter parameter = new FreeTypeFontParameter();
@ -77,7 +83,8 @@ public class ScreenBattle extends RenderingScreen{
g.drawFilledRectangle(Settings.SIDE/2, HEIGHT_DIALOG/2 + EDGE, WIDTH_DIALOG, HEIGHT_DIALOG, 0);
//dialog
g.drawString(15, 245 ,battle.getLine() , optimus40);
if(b != null) g.drawString(15, 245 ,b.getLine() , optimus40);
@ -95,7 +102,7 @@ public class ScreenBattle extends RenderingScreen{
//TODO afficher le joueur
}
public void manage(Controller c){
public void manage(Controller c, Battle battle){
if(PokeMudry.front_montant){
System.out.println("manage: " + battle.getLineSpeech());

View File

@ -2,14 +2,16 @@ package Screen;
import Entity.Enemy;
import Entity.Player;
import Game.Battle;
import ch.hevs.gdx2d.lib.GdxGraphics;
public class ScreenPlayer {
public ManagerOfScreen screenManager = new ManagerOfScreen();
public Player p;
public Enemy e;
public ScreenMap sm;
public ScreenBattle sb;
public Player p = null;
public Enemy e = null;
public Battle b = null;
public ScreenMap sm = null;
public ScreenBattle sb = null;
public void init(){
@ -19,13 +21,18 @@ public class ScreenPlayer {
// Create both type of screen and record for reuse
screenManager.registerScreen(ScreenMap.class);
screenManager.registerScreen(ScreenBattle.class);
sb = screenManager.getScreenBattle();
sm = screenManager.getScreenMap();
}
public void render(GdxGraphics g){
sb.setEnemy(e);
sm.setPlayer(p);
if(sb != null){
sb.setEnemy(e);
sb.setBattle(b);
}
screenManager.render(g);
}