added display for player stats
This commit is contained in:
@@ -49,6 +49,9 @@ public class UI {
|
||||
case TITLE:
|
||||
drawTitleScreen();
|
||||
break;
|
||||
case CHARACTER:
|
||||
drawCharacterScreen();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -141,6 +144,53 @@ public class UI {
|
||||
graphics2d.drawString(text, x, y);
|
||||
if(commandNum == 2) graphics2d.drawString(">", x-panel.tileSize, y);
|
||||
}
|
||||
public void drawCharacterScreen() {
|
||||
// DRAW FRAME
|
||||
final int frameX = panel.tileSize;
|
||||
final int frameY = panel.tileSize;
|
||||
final int frameWidth = panel.tileSize*5;
|
||||
final int frameHeight = panel.tileSize*10;
|
||||
drawSubWindow(frameX, frameY, frameWidth, frameHeight);
|
||||
|
||||
// TEXT
|
||||
graphics2d.setColor(Color.white);
|
||||
graphics2d.setFont(graphics2d.getFont().deriveFont(22F));
|
||||
|
||||
int textX = frameX + 20;
|
||||
int textY = frameY + panel.tileSize;
|
||||
final int lineHeight = 35;
|
||||
|
||||
// NAMES
|
||||
String[] names = {"Level", "Life", "Strength", "Dexterity", "Attack", "Defense", "Exp", "Next Level", "Coins", "Weapon", "Shield"};
|
||||
for(String name : names) {
|
||||
graphics2d.drawString(name, textX, textY);
|
||||
textY += lineHeight + (name.equals("Coins") ? 20 : (name.equals("Weapon") ? 15 : 0));
|
||||
}
|
||||
|
||||
// VALUES
|
||||
int tailX = (frameX + frameWidth) - 30;
|
||||
textY = frameY + panel.tileSize;
|
||||
String[] values = {
|
||||
String.valueOf(panel.player.level),
|
||||
(panel.player.life + "/" + panel.player.maxLife),
|
||||
String.valueOf(panel.player.strength),
|
||||
String.valueOf(panel.player.dexterity),
|
||||
String.valueOf(panel.player.attack),
|
||||
String.valueOf(panel.player.defense),
|
||||
String.valueOf(panel.player.exp),
|
||||
String.valueOf(panel.player.nextLevelExp),
|
||||
String.valueOf(panel.player.coins)
|
||||
};
|
||||
for(String value : values) {
|
||||
textX = getAlignedToRightX(value, tailX);
|
||||
graphics2d.drawString(value, textX, textY);
|
||||
textY += lineHeight;
|
||||
}
|
||||
|
||||
graphics2d.drawImage(panel.player.currentWeapon.down1, tailX - panel.tileSize, textY-14, null);
|
||||
textY += panel.tileSize;
|
||||
graphics2d.drawImage(panel.player.currentShield.down1, tailX - panel.tileSize, textY-14, null);
|
||||
}
|
||||
|
||||
// UTILITY
|
||||
public void drawSubWindow(int x, int y, int width, int height) {
|
||||
@@ -153,5 +203,8 @@ public class UI {
|
||||
public int getCenteredX(String text) {
|
||||
return panel.screenWidth / 2 - (int) graphics2d.getFontMetrics().getStringBounds(text, graphics2d).getWidth() / 2;
|
||||
}
|
||||
public int getAlignedToRightX(String text, int tailX) {
|
||||
return tailX - (int) graphics2d.getFontMetrics().getStringBounds(text, graphics2d).getWidth() / 2;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user