added notifications and added leveling system
This commit is contained in:
@@ -6,6 +6,7 @@ import de.miaurizius.jgame2d.entity.item.HeartObj;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class UI {
|
||||
|
||||
@@ -13,6 +14,8 @@ public class UI {
|
||||
Graphics2D graphics2d;
|
||||
Font arial_40, arial_80B; //TODO: Custom font loader: https://www.youtube.com/watch?v=g-wrebFVP3E
|
||||
BufferedImage heart_full, heart_half, heart_blank;
|
||||
ArrayList<String> messages = new ArrayList<>();
|
||||
ArrayList<Integer> messageCounter = new ArrayList<>();
|
||||
public String currentDialogue;
|
||||
public int commandNum;
|
||||
|
||||
@@ -36,14 +39,12 @@ public class UI {
|
||||
if(panel.gameState == null) return;
|
||||
switch (panel.gameState) {
|
||||
case GameState.PLAY:
|
||||
drawPlayerLife();
|
||||
drawPlayScreen();
|
||||
break;
|
||||
case GameState.PAUSE:
|
||||
drawPlayerLife();
|
||||
drawPauseScreen();
|
||||
break;
|
||||
case GameState.DIALOGUE:
|
||||
drawPlayerLife();
|
||||
drawDialogueScreen();
|
||||
break;
|
||||
case TITLE:
|
||||
@@ -81,15 +82,38 @@ public class UI {
|
||||
x += panel.tileSize;
|
||||
}
|
||||
}
|
||||
public void drawMessages() {
|
||||
int messageX = panel.tileSize;
|
||||
int messageY = panel.tileSize*4;
|
||||
graphics2d.setFont(graphics2d.getFont().deriveFont(Font.BOLD, 32F));
|
||||
|
||||
for(int i = 0; i < messages.size(); i++) {
|
||||
if(messages.get(i) == null) return;
|
||||
|
||||
graphics2d.setColor(Color.black);
|
||||
graphics2d.drawString(messages.get(i), messageX+2, messageY+2);
|
||||
graphics2d.setColor(Color.white);
|
||||
graphics2d.drawString(messages.get(i), messageX, messageY);
|
||||
|
||||
messageCounter.set(i, messageCounter.get(i) + 1);
|
||||
messageY += 50;
|
||||
if(messageCounter.get(i) > 180) {
|
||||
messages.remove(i);
|
||||
messageCounter.remove(i);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// GAME STATES
|
||||
public void drawPauseScreen() {
|
||||
drawPlayerLife();
|
||||
graphics2d.setFont(graphics2d.getFont().deriveFont(Font.PLAIN, 80));
|
||||
String text = "PAUSED";
|
||||
int y = panel.screenHeight / 2;
|
||||
graphics2d.drawString(text, getCenteredX(text), y);
|
||||
}
|
||||
public void drawDialogueScreen() {
|
||||
drawPlayerLife();
|
||||
// WINDOW
|
||||
int x = panel.tileSize*2;
|
||||
int y = panel.tileSize/2;
|
||||
@@ -191,6 +215,10 @@ public class UI {
|
||||
textY += panel.tileSize;
|
||||
graphics2d.drawImage(panel.player.currentShield.down1, tailX - panel.tileSize, textY-14, null);
|
||||
}
|
||||
public void drawPlayScreen() {
|
||||
drawPlayerLife();
|
||||
drawMessages();
|
||||
}
|
||||
|
||||
// UTILITY
|
||||
public void drawSubWindow(int x, int y, int width, int height) {
|
||||
@@ -206,5 +234,9 @@ public class UI {
|
||||
public int getAlignedToRightX(String text, int tailX) {
|
||||
return tailX - (int) graphics2d.getFontMetrics().getStringBounds(text, graphics2d).getWidth() / 2;
|
||||
}
|
||||
public void addMessage(String text) {
|
||||
messages.add(text);
|
||||
messageCounter.add(0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user