InfoPanel.java 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. package model.objects;
  2. import java.awt.Color;
  3. import java.awt.Font;
  4. import java.awt.Graphics2D;
  5. import model.gameState.PlayState;
  6. public class InfoPanel {
  7. private String totalHighscore = "XXXXXX";
  8. private int lifePercent;
  9. private int upgradeScore = 0;
  10. private int x, y;
  11. public InfoPanel(int x, int y){
  12. this.x = x;
  13. this.y = y;
  14. updateIPanel();
  15. }
  16. public void updateIPanel() {
  17. totalHighscore = "Score: " + PlayState.currentScore;
  18. lifePercent =+ PlayState.lifePoints;
  19. if(0 <= PlayState.currentScore && PlayState.currentScore <=100) {
  20. upgradeScore = PlayState.currentScore;
  21. }
  22. if(PlayState.currentScore == 100) {
  23. }
  24. }
  25. public void draw(Graphics2D g2){
  26. g2.setColor(Color.BLACK);
  27. g2.fillRect(x, y, 256, 1024);
  28. Font scoreFont = new Font("OCR A Extended", Font.BOLD, 30);
  29. g2.setFont(scoreFont);
  30. g2.setColor(Color.ORANGE);
  31. g2.drawString(totalHighscore, 25, 75);
  32. g2.drawRect(25, 100, 200, 30);
  33. g2.drawRect(25, 300, 200, 700);
  34. g2.setColor(Color.GREEN);
  35. g2.fillRect(25, 100, 2 * lifePercent, 30);
  36. g2.setColor(Color.YELLOW);
  37. g2.fillRect(25, 1000 - 7 * upgradeScore, 200, 0 + 7 * upgradeScore);
  38. g2.setColor(Color.BLACK);
  39. }
  40. }