mirror of
https://github.com/Klagarge/PokeHES.git
synced 2024-11-26 19:13:27 +00:00
Merge pull request #37 from Klagarge/battlescreen-display
Battlescreen-display
This commit is contained in:
commit
da6d94945b
BIN
Data/img/Mudry.png
Normal file
BIN
Data/img/Mudry.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 59 KiB |
BIN
Data/img/Player.png
Normal file
BIN
Data/img/Player.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 31 KiB |
BIN
Data/img/enemy.png
Normal file
BIN
Data/img/enemy.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 59 KiB |
@ -29,6 +29,7 @@ public abstract class Character extends Entity{
|
|||||||
int nFrames = 4;
|
int nFrames = 4;
|
||||||
final float FRAME_TIME = 0.1f; // Duration of each frime
|
final float FRAME_TIME = 0.1f; // Duration of each frime
|
||||||
private String img;
|
private String img;
|
||||||
|
private String imgBattle;
|
||||||
|
|
||||||
protected int pv;
|
protected int pv;
|
||||||
|
|
||||||
@ -43,6 +44,8 @@ public abstract class Character extends Entity{
|
|||||||
public Character(String name, int x, int y, String img, String map){
|
public Character(String name, int x, int y, String img, String map){
|
||||||
super(name, x, y, map);
|
super(name, x, y, map);
|
||||||
this.img = img;
|
this.img = img;
|
||||||
|
|
||||||
|
imgBattle = "./Data/img/" + name + ".png";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -163,4 +166,8 @@ public abstract class Character extends Entity{
|
|||||||
}
|
}
|
||||||
|
|
||||||
abstract protected void removedPv(int pv);
|
abstract protected void removedPv(int pv);
|
||||||
|
|
||||||
|
public String getImgBattle(){
|
||||||
|
return imgBattle;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,8 +9,7 @@ public class Enemy extends Character{
|
|||||||
private String branch;
|
private String branch;
|
||||||
public int recoveredTime = Settings.RECOVERED;
|
public int recoveredTime = Settings.RECOVERED;
|
||||||
|
|
||||||
|
private int pvInit;
|
||||||
|
|
||||||
|
|
||||||
public Enemy(String name, int x, int y, String img, String map, int pv, String branch, Character.Direction dir) {
|
public Enemy(String name, int x, int y, String img, String map, int pv, String branch, Character.Direction dir) {
|
||||||
|
|
||||||
@ -24,6 +23,9 @@ public class Enemy extends Character{
|
|||||||
this.branch = branch;
|
this.branch = branch;
|
||||||
|
|
||||||
this.pv = pv;
|
this.pv = pv;
|
||||||
|
|
||||||
|
pvInit = pv;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPosition(int x, int y, String map){
|
public void setPosition(int x, int y, String map){
|
||||||
@ -51,4 +53,9 @@ public class Enemy extends Character{
|
|||||||
return (pv<0) ? 0 : pv;
|
return (pv<0) ? 0 : pv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getPvInit(){
|
||||||
|
return pvInit;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,7 @@ public class Player extends Character{
|
|||||||
private int xp = 0;
|
private int xp = 0;
|
||||||
public Enemy lastEnemy = null;
|
public Enemy lastEnemy = null;
|
||||||
public boolean onEnemy = false;
|
public boolean onEnemy = false;
|
||||||
|
private static final int XP_MAX = 6000;
|
||||||
|
|
||||||
public Player(int x, int y, String map) {
|
public Player(int x, int y, String map) {
|
||||||
super("Player", x, y, "Character_flipped", map);
|
super("Player", x, y, "Character_flipped", map);
|
||||||
@ -122,4 +123,8 @@ public class Player extends Character{
|
|||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getXpMax(){
|
||||||
|
return XP_MAX;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,14 @@
|
|||||||
package Game;
|
package Game;
|
||||||
|
|
||||||
import Entity.Enemy;
|
import Entity.Enemy;
|
||||||
|
import Entity.Player;
|
||||||
import Text.TextEnemy;
|
import Text.TextEnemy;
|
||||||
|
|
||||||
public class Battle {
|
public class Battle {
|
||||||
|
|
||||||
private Enemy e;
|
public Enemy e;
|
||||||
|
public Player player;
|
||||||
|
|
||||||
public TextEnemy textEnemy;
|
public TextEnemy textEnemy;
|
||||||
private int lineSpeech;
|
private int lineSpeech;
|
||||||
|
|
||||||
@ -141,4 +144,7 @@ public class Battle {
|
|||||||
public void setEnemy(Enemy e){
|
public void setEnemy(Enemy e){
|
||||||
this.e = e;
|
this.e = e;
|
||||||
}
|
}
|
||||||
|
public void setPlayer(Player p){
|
||||||
|
this.player = p;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -77,6 +77,8 @@ public class PokeMudry extends PortableApplication {
|
|||||||
|
|
||||||
if(onMapScreen) sp.p.manageEntity(sp.sm, controller);
|
if(onMapScreen) sp.p.manageEntity(sp.sm, controller);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Switch screen
|
// Switch screen
|
||||||
if (sp.p.onEnemy && onMapScreen){
|
if (sp.p.onEnemy && onMapScreen){
|
||||||
sp.e = sp.p.lastEnemy;
|
sp.e = sp.p.lastEnemy;
|
||||||
@ -84,9 +86,12 @@ public class PokeMudry extends PortableApplication {
|
|||||||
int pv = sp.e.getPv();
|
int pv = sp.e.getPv();
|
||||||
boolean recovered = sp.e.recoveredTime>=Settings.RECOVERED;
|
boolean recovered = sp.e.recoveredTime>=Settings.RECOVERED;
|
||||||
|
|
||||||
|
|
||||||
if (pv>0 && recovered) {
|
if (pv>0 && recovered) {
|
||||||
sp.sb = sp.screenManager.getScreenBattle();
|
sp.sb = sp.screenManager.getScreenBattle();
|
||||||
|
|
||||||
sp.b = new Battle(sp.e);
|
sp.b = new Battle(sp.e);
|
||||||
|
sp.sb = sp.screenManager.getScreenBattle();
|
||||||
|
|
||||||
//set pv and xp to display
|
//set pv and xp to display
|
||||||
sp.b.setXpPlayer(sp.p.getXp());
|
sp.b.setXpPlayer(sp.p.getXp());
|
||||||
|
@ -14,6 +14,7 @@ import Entity.Player;
|
|||||||
import Game.Battle;
|
import Game.Battle;
|
||||||
import Main.PokeMudry;
|
import Main.PokeMudry;
|
||||||
import Main.Settings;
|
import Main.Settings;
|
||||||
|
import ch.hevs.gdx2d.components.bitmaps.BitmapImage;
|
||||||
import ch.hevs.gdx2d.components.screen_management.RenderingScreen;
|
import ch.hevs.gdx2d.components.screen_management.RenderingScreen;
|
||||||
import ch.hevs.gdx2d.lib.GdxGraphics;
|
import ch.hevs.gdx2d.lib.GdxGraphics;
|
||||||
|
|
||||||
@ -23,14 +24,20 @@ public class ScreenBattle extends RenderingScreen{
|
|||||||
private static int HEIGHT_DIALOG = Settings.SIDE / 3;
|
private static int HEIGHT_DIALOG = Settings.SIDE / 3;
|
||||||
private static int WIDTH_DIALOG = Settings.SIDE - 2*EDGE;
|
private static int WIDTH_DIALOG = Settings.SIDE - 2*EDGE;
|
||||||
|
|
||||||
private BitmapFont optimus40;
|
private BitmapFont unbuntuRegularBlack;
|
||||||
|
private BitmapFont unbuntuRegularWhite;
|
||||||
|
private BitmapImage enemyImg;
|
||||||
|
private BitmapImage playerImg;
|
||||||
|
|
||||||
private Battle b = null;
|
private Battle b = null;
|
||||||
|
|
||||||
|
private Enemy enemy;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onInit() {
|
public void onInit() {
|
||||||
//display the question
|
//display the question
|
||||||
generateFont("./Data/font/Ubuntu-Regular.ttf", 30, Color.BLACK);
|
unbuntuRegularBlack = generateFont("./Data/font/Ubuntu-Regular.ttf", 30, Color.BLACK);
|
||||||
|
unbuntuRegularWhite = generateFont("./Data/font/Ubuntu-Regular.ttf", 45, Color.WHITE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -38,11 +45,19 @@ public class ScreenBattle extends RenderingScreen{
|
|||||||
public void onGraphicRender(GdxGraphics g) {
|
public void onGraphicRender(GdxGraphics g) {
|
||||||
g.clear(Color.BLACK);
|
g.clear(Color.BLACK);
|
||||||
displayDialog(g);
|
displayDialog(g);
|
||||||
|
displayEnemy(g);
|
||||||
|
displayPlayer(g);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void dispose() {
|
public void dispose() {
|
||||||
optimus40.dispose();
|
unbuntuRegularBlack.dispose();
|
||||||
|
unbuntuRegularWhite.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setImg(){
|
||||||
|
enemyImg = new BitmapImage(b.e.getImgBattle()); //width : 192, height : 240
|
||||||
|
playerImg = new BitmapImage(b.player.getImgBattle());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -50,16 +65,17 @@ public class ScreenBattle extends RenderingScreen{
|
|||||||
this.b = battle;
|
this.b = battle;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void generateFont(String file, int height, Color c ){
|
public BitmapFont generateFont(String file, int height, Color c ){
|
||||||
|
|
||||||
//Generate font with the file .ttf
|
//Generate font with the file .ttf
|
||||||
|
BitmapFont font;
|
||||||
FileHandle fileHandle = Gdx.files.internal(file);
|
FileHandle fileHandle = Gdx.files.internal(file);
|
||||||
FreeTypeFontParameter parameter = new FreeTypeFontParameter();
|
FreeTypeFontParameter parameter = new FreeTypeFontParameter();
|
||||||
FreeTypeFontGenerator generator = new FreeTypeFontGenerator(fileHandle);
|
FreeTypeFontGenerator generator = new FreeTypeFontGenerator(fileHandle);
|
||||||
parameter.size = generator.scaleForPixelHeight(height);
|
parameter.size = generator.scaleForPixelHeight(height);
|
||||||
parameter.color = c;
|
parameter.color = c;
|
||||||
optimus40 = generator.generateFont(parameter);
|
font = generator.generateFont(parameter);
|
||||||
generator.dispose();
|
generator.dispose();
|
||||||
|
return font;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,16 +86,26 @@ public class ScreenBattle extends RenderingScreen{
|
|||||||
//dialog
|
//dialog
|
||||||
if(b == null) return;
|
if(b == null) return;
|
||||||
if(b.getLine() == null) return;
|
if(b.getLine() == null) return;
|
||||||
g.drawString(15, 260 ,b.getLine() , optimus40);
|
g.drawString(15, 260 ,b.getLine() , unbuntuRegularBlack);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void displayEnemy(Enemy e){
|
|
||||||
// TODO affficher l'enemi
|
public void displayEnemy(GdxGraphics g){
|
||||||
|
//draw image
|
||||||
|
g.drawPicture(Settings.SIDE - (192/2), Settings.SIDE-240/2, enemyImg);
|
||||||
|
//draw pv
|
||||||
|
g.drawString(350, Settings.SIDE - 15 , "PV : " + b.pvEnemy + " / " + b.e.getPvInit(), unbuntuRegularWhite);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void displayPlayer(Player p){
|
public void displayPlayer(GdxGraphics g){
|
||||||
//TODO afficher le joueur
|
//draw image
|
||||||
|
|
||||||
|
g.drawPicture((192/2), HEIGHT_DIALOG + 10 + 240/2, playerImg);
|
||||||
|
//draw pv
|
||||||
|
g.drawString(255, HEIGHT_DIALOG + 100 , "XP : " + b.xpPlayer + " / " + b.player.getXpMax() + "\nPV : " + b.player.getPv() + " / " + Settings.TIME*60, unbuntuRegularWhite);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -20,7 +20,8 @@ public class ScreenPlayer {
|
|||||||
//p = new Player(8, 15, "desert");
|
//p = new Player(8, 15, "desert");
|
||||||
p = new Player(4, 2, "21RI");
|
p = new Player(4, 2, "21RI");
|
||||||
|
|
||||||
b = new Battle(new Enemy("enemy", 0, 0, "lumberjack_sheet32", "desert", 50, "enemy",Direction.NULL));
|
e = new Enemy("enemy", 0, 0, "lumberjack_sheet32", "desert", 50, "enemy",Direction.NULL);
|
||||||
|
b = new Battle(e);
|
||||||
|
|
||||||
// Create both type of screen and record for reuse
|
// Create both type of screen and record for reuse
|
||||||
screenManager.registerScreen(ScreenMap.class);
|
screenManager.registerScreen(ScreenMap.class);
|
||||||
@ -38,6 +39,8 @@ public class ScreenPlayer {
|
|||||||
if(sb != null){
|
if(sb != null){
|
||||||
sb.setBattle(b);
|
sb.setBattle(b);
|
||||||
b.setEnemy(e);
|
b.setEnemy(e);
|
||||||
|
b.setPlayer(p);
|
||||||
|
sb.setImg();
|
||||||
}
|
}
|
||||||
|
|
||||||
screenManager.render(g);
|
screenManager.render(g);
|
||||||
|
Loading…
Reference in New Issue
Block a user