PreGameState.java 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. package model.gameState;
  2. import image.Images;
  3. import java.awt.BasicStroke;
  4. import java.awt.Color;
  5. import java.awt.Font;
  6. import java.awt.Graphics2D;
  7. import java.awt.image.BufferedImage;
  8. import model.SongHandler;
  9. import control.GameStateManager;
  10. import control.button.ButtonEvent;
  11. import control.joystick.JoystickEvent;
  12. public class PreGameState extends GameState {
  13. double index2 = 3;
  14. double index = 3;
  15. double timer;
  16. int grootte = 150;
  17. BasicStroke s = new BasicStroke(20);
  18. BufferedImage screenshot;
  19. public PreGameState(GameStateManager gsm, SongHandler sh) {
  20. super(gsm, sh);
  21. screenshot = Images.getImage(Images.ImageType.screenshot);
  22. }
  23. @Override
  24. public void init() {
  25. }
  26. @Override
  27. public void update(float factor) {
  28. // timer = timer +factor/1000;
  29. // index -= timer;
  30. index2 -= factor/1000;
  31. index = (double) Math.round(index2*1000)/1000;
  32. if(index <= 0){
  33. gsm.setState(control.GameStateManager.State.PLAY_STATE);
  34. }
  35. if(grootte > 270)
  36. grootte = 150;
  37. grootte+=2;
  38. }
  39. @Override
  40. public void draw(Graphics2D g2) {
  41. g2.drawImage(screenshot,0,0,1280,1024,null);
  42. Font textFont = new Font("OCR A Extended", Font.BOLD,grootte);
  43. g2.setFont(textFont);
  44. g2.setStroke(s);
  45. g2.setColor(Color.RED);
  46. String text = "" + index;
  47. int width = g2.getFontMetrics().stringWidth(text);
  48. g2.drawString(text, 325, 400);
  49. if(index < 1){
  50. text = "GO!!!";
  51. // width = g2.getFontMetrics().stringWidth("GO!!!");
  52. // g2.drawString("GO!!!",325,600);
  53. }
  54. else if (index < 2){
  55. text = "SET";
  56. // width = g2.getFontMetrics().stringWidth("SET");
  57. // g2.drawString("SET", 450,600);
  58. }
  59. else{
  60. text = "READY";
  61. // width = g2.getFontMetrics().stringWidth("READY");
  62. // g2.drawString("READY", 325, 600);
  63. }
  64. width = g2.getFontMetrics().stringWidth(text);
  65. g2.drawString(text, (256+1024/2)-width/2, 600);
  66. }
  67. @Override
  68. public void buttonPressed(ButtonEvent e) {
  69. }
  70. @Override
  71. public void buttonReleased(ButtonEvent e) {
  72. }
  73. @Override
  74. public void onJoystickMoved(JoystickEvent e) {
  75. }
  76. }