TitleState.java 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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.Graphics2D;
  7. import java.awt.image.BufferedImage;
  8. import control.GameStateManager;
  9. import control.button.ButtonEvent;
  10. import control.joystick.JoystickEvent;
  11. public class TitleState extends GameState {
  12. BufferedImage pressStart = Images.getImage(ImageType.pressstart);
  13. BufferedImage colorStrike = Images.getImage(ImageType.colorstrike);
  14. BufferedImage background = Images.getImage(ImageType.background);
  15. int index = 0;
  16. int varx = 0;
  17. int frame = 0;
  18. int maxFrames = 2560;
  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(Color.WHITE);
  33. g2.fillRect(0,0,1280,1024);
  34. g2.translate(640, 512);
  35. BufferedImage subImg2 = background.getSubimage(0, 0, 5120, 1024);
  36. g2.drawImage(subImg2, -640 -((frame * 4) % maxFrames), -512, 5120, 1024, null);
  37. //
  38. // g2.setColor(Color.ORANGE);
  39. // g2.fillRect( -25*5 -1, - 18*5 -1, 49*5 + 1, 26*5 + 1);
  40. // g2.drawRect( -25*5 -3, - 18*5 -3, 49*5 + 4, 26*5 + 4);
  41. int image_x = ((frame / 6) % 6) * 49;
  42. BufferedImage subImg = pressStart.getSubimage(image_x, 0, 49, 26);
  43. g2.drawImage(subImg, - 25*5, - 18*5, 49*5, 26*5, null);
  44. g2.drawImage(colorStrike, -27*8 , -300, 54*8, 18*8, null);
  45. Font textFont = new Font("OCR A Extended", Font.BOLD, 15);
  46. g2.setFont(textFont);
  47. g2.setColor(Color.WHITE);
  48. g2.drawString("©2015 Team Hamtaro", - 18*5, 500);
  49. }
  50. @Override
  51. public void buttonPressed(ButtonEvent e) {
  52. switch(e.getButton().getButtonID()){
  53. case 0:
  54. gsm.next();
  55. break;
  56. }
  57. }
  58. @Override
  59. public void buttonReleased(ButtonEvent e) {
  60. }
  61. @Override
  62. public void onJoystickMoved(JoystickEvent e) {
  63. // TODO Auto-generated method stub
  64. }
  65. }