InfoPanel.java 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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.fillRect(x, y, 256, 1024);
  27. Font scoreFont = new Font("OCR A Extended", Font.BOLD, 30);
  28. g2.setFont(scoreFont);
  29. g2.setColor(Color.ORANGE);
  30. g2.drawString(totalHighscore, 25, 75);
  31. g2.drawRect(25, 100, 200, 30);
  32. g2.drawRect(25, 300, 200, 700);
  33. g2.setColor(Color.GREEN);
  34. g2.fillRect(25, 100, 2 * lifePercent, 30);
  35. g2.setColor(Color.YELLOW);
  36. g2.fillRect(25, 1000 - 7 * upgradeScore, 200, 0 + 7 * upgradeScore);
  37. g2.setColor(Color.BLACK);
  38. }
  39. }