mirror of
https://github.com/Klagarge/PokeHES.git
synced 2025-01-30 20:52:44 +00:00
add xp and pv on display
This commit is contained in:
parent
a5c3c8bac5
commit
cad32fde7d
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;
|
||||
final float FRAME_TIME = 0.1f; // Duration of each frime
|
||||
private String img;
|
||||
private String imgBattle;
|
||||
|
||||
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){
|
||||
super(name, x, y, map);
|
||||
this.img = img;
|
||||
|
||||
imgBattle = "./Data/img/" + name + ".png";
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -163,4 +166,8 @@ public abstract class Character extends Entity{
|
||||
}
|
||||
|
||||
abstract protected void removedPv(int pv);
|
||||
|
||||
public String getImgBattle(){
|
||||
return imgBattle;
|
||||
}
|
||||
}
|
||||
|
@ -6,8 +6,7 @@ public class Enemy extends Character{
|
||||
|
||||
private String branch;
|
||||
|
||||
|
||||
|
||||
private int pvInit;
|
||||
|
||||
public Enemy(String name, int x, int y, String img, String map, int pv, String branch, Character.Direction dir) {
|
||||
|
||||
@ -21,6 +20,9 @@ public class Enemy extends Character{
|
||||
this.branch = branch;
|
||||
|
||||
this.pv = pv;
|
||||
|
||||
pvInit = pv;
|
||||
|
||||
}
|
||||
|
||||
public void setPosition(int x, int y, String map){
|
||||
@ -47,5 +49,10 @@ public class Enemy extends Character{
|
||||
//the pv can go under 0, but his real pv is 0 (for the player)
|
||||
return (pv<0) ? 0 : pv;
|
||||
}
|
||||
|
||||
public int getPvInit(){
|
||||
return pvInit;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -15,6 +15,7 @@ public class Player extends Character{
|
||||
private int xp = 0;
|
||||
public Enemy lastEnemy = null;
|
||||
public boolean onEnemy = false;
|
||||
private static final int XP_MAX = 6000;
|
||||
|
||||
public Player(int x, int y, String map) {
|
||||
super("Player", x, y, "Character_flipped", map);
|
||||
@ -119,4 +120,8 @@ public class Player extends Character{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
public int getXpMax(){
|
||||
return XP_MAX;
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,14 @@
|
||||
package Game;
|
||||
|
||||
import Entity.Enemy;
|
||||
import Entity.Player;
|
||||
import Text.TextEnemy;
|
||||
|
||||
public class Battle {
|
||||
|
||||
private Enemy e;
|
||||
public Enemy e;
|
||||
public Player player;
|
||||
|
||||
public TextEnemy textEnemy;
|
||||
private int lineSpeech;
|
||||
|
||||
@ -140,4 +143,7 @@ public class Battle {
|
||||
public void setEnemy(Enemy e){
|
||||
this.e = e;
|
||||
}
|
||||
public void setPlayer(Player p){
|
||||
this.player = p;
|
||||
}
|
||||
}
|
||||
|
@ -66,6 +66,8 @@ public class PokeMudry extends PortableApplication {
|
||||
|
||||
if(onMapScreen) sp.p.manageEntity(sp.sm, controller);
|
||||
|
||||
|
||||
|
||||
// Switch screen
|
||||
if (sp.p.onEnemy && onMapScreen){
|
||||
sp.e = sp.p.lastEnemy;
|
||||
@ -73,8 +75,9 @@ public class PokeMudry extends PortableApplication {
|
||||
int pv = sp.e.getPv();
|
||||
|
||||
if (pv>0) {
|
||||
sp.sb = sp.screenManager.getScreenBattle();
|
||||
|
||||
sp.b = new Battle(sp.e);
|
||||
sp.sb = sp.screenManager.getScreenBattle();
|
||||
|
||||
//set pv and xp to display
|
||||
sp.b.setXpPlayer(sp.p.getXp());
|
||||
|
@ -46,6 +46,7 @@ public class ScreenBattle extends RenderingScreen{
|
||||
g.clear(Color.BLACK);
|
||||
displayDialog(g);
|
||||
displayEnemy(g);
|
||||
displayPlayer(g);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -56,7 +57,7 @@ public class ScreenBattle extends RenderingScreen{
|
||||
|
||||
public void setImg(){
|
||||
enemyImg = new BitmapImage(b.e.getImgBattle()); //width : 192, height : 240
|
||||
enemyImg = new BitmapImage(b);
|
||||
playerImg = new BitmapImage(b.player.getImgBattle());
|
||||
}
|
||||
|
||||
|
||||
@ -94,16 +95,17 @@ public class ScreenBattle extends RenderingScreen{
|
||||
//draw image
|
||||
g.drawPicture(Settings.SIDE - (192/2), Settings.SIDE-240/2, enemyImg);
|
||||
//draw pv
|
||||
g.drawString(250, Settings.SIDE - 15 , "PV : " + b.pvEnemy , unbuntuRegularWhite);
|
||||
g.drawString(350, Settings.SIDE - 15 , "PV : " + b.pvEnemy + " / " + b.e.getPvInit(), unbuntuRegularWhite);
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void displayPlayer(GdxGraphics g){
|
||||
//draw image
|
||||
g.drawPicture(Settings.SIDE - (192/2), Settings.SIDE-240/2, playerImg);
|
||||
|
||||
g.drawPicture((192/2), HEIGHT_DIALOG + 10 + 240/2, playerImg);
|
||||
//draw pv
|
||||
g.drawString(250, Settings.SIDE - 15 , "PV : " + b.pvEnemy , unbuntuRegularWhite);
|
||||
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(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
|
||||
screenManager.registerScreen(ScreenMap.class);
|
||||
@ -38,6 +39,8 @@ public class ScreenPlayer {
|
||||
if(sb != null){
|
||||
sb.setBattle(b);
|
||||
b.setEnemy(e);
|
||||
b.setPlayer(p);
|
||||
sb.setImg();
|
||||
}
|
||||
|
||||
screenManager.render(g);
|
||||
|
Loading…
x
Reference in New Issue
Block a user