TitleState.java 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. package model.gameState;
  2. import image.Images;
  3. import image.Images.ImageType;
  4. import java.awt.Color;
  5. import java.awt.Font;
  6. import java.awt.GradientPaint;
  7. import java.awt.Graphics2D;
  8. import java.awt.image.BufferedImage;
  9. import control.GameStateManager;
  10. import control.button.ButtonEvent;
  11. import control.joystick.JoystickEvent;
  12. public class TitleState extends GameState {
  13. BufferedImage pressStart = Images.getImage(ImageType.pressstart);
  14. BufferedImage colorStrike = Images.getImage(ImageType.colorstrike);
  15. BufferedImage background = Images.getImage(ImageType.background);
  16. int index = 0;
  17. int varx = 0;
  18. int frame;
  19. public TitleState(GameStateManager gsm) {
  20. super(gsm);
  21. }
  22. @Override
  23. public void init() {
  24. // TODO Auto-generated method stub
  25. }
  26. @Override
  27. public void update() {
  28. frame++;
  29. }
  30. @Override
  31. public void draw(Graphics2D g2) {
  32. g2.setColor(new Color(1,1,1, 0.3f));
  33. g2.fillRect(0,0,1280,1024);
  34. g2.setColor(new Color(0,1,0, 0.7f));
  35. g2.fillRect(0,0,100,1024);
  36. g2.setColor(new Color(1,1,0, 0.7f));
  37. g2.fillRect(100,0,100,1024);
  38. g2.setColor(new Color(1,0,0, 0.7f));
  39. g2.fillRect(200,0,100,1024);
  40. g2.setColor(new Color(0,1,0, 0.7f));
  41. g2.fillRect(1180,0,100,1024);
  42. g2.setColor(new Color(1,1,0, 0.7f));
  43. g2.fillRect(1080,0,100,1024);
  44. g2.setColor(new Color(1,0,0, 0.7f));
  45. g2.fillRect(980,0,100,1024);
  46. GradientPaint gp = new GradientPaint(300, 0, new Color(0,0,1, 0.6f),980,1024 ,new Color(0,0,1, 0.2f));
  47. g2.setPaint(gp);
  48. g2.fillRect(300, 0, 680, 1024);
  49. g2.translate(640, 512);
  50. int image_x = ((frame / 6) % 6) * 49;
  51. BufferedImage subImg = pressStart.getSubimage(image_x, 0, 49, 26);
  52. g2.drawImage(subImg, - 25*5, 200, 49*5, 26*5, null);
  53. Font textFont = new Font("OCR A Extended", Font.BOLD, 15);
  54. g2.setFont(textFont);
  55. g2.setColor(Color.WHITE);
  56. g2.drawString("©2015 Team Hamtaro", - 18*5, 500);
  57. g2.setColor(Color.RED);
  58. Font textFont2 = new Font("OCR A Extended", Font.BOLD, 130);
  59. g2.setFont(textFont2);
  60. g2.drawString("Color", -215, -300);
  61. g2.drawString("Strike", -250, -170);
  62. }
  63. @Override
  64. public void buttonPressed(ButtonEvent e) {
  65. switch(e.getButton().getButtonID()){
  66. case 0:
  67. gsm.next();
  68. break;
  69. }
  70. }
  71. @Override
  72. public void buttonReleased(ButtonEvent e) {
  73. }
  74. @Override
  75. public void onJoystickMoved(JoystickEvent e) {
  76. // TODO Auto-generated method stub
  77. }
  78. }