TitleState.java 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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. int index = 0;
  15. int varx = 0;
  16. int x,y,frame = 0,maxFrames = 5;
  17. public TitleState(GameStateManager gsm) {
  18. super(gsm);
  19. }
  20. @Override
  21. public void init() {
  22. // TODO Auto-generated method stub
  23. }
  24. @Override
  25. public void update() {
  26. if(frame == maxFrames-1){
  27. x = (index % 6)*49;
  28. y = 0;
  29. index++;
  30. index %= 6;
  31. }
  32. frame++;
  33. frame %= (maxFrames);
  34. }
  35. @Override
  36. public void draw(Graphics2D g2) {
  37. g2.setColor(Color.BLACK);
  38. g2.fillRect(0, 0, 1280, 1024);
  39. g2.setColor(Color.ORANGE);
  40. g2.fillRect(1280/2 -120, 1024/2 - 80, 225, 90);
  41. g2.drawRect(1280/2 -122, 1024/2 - 82, 228, 93);
  42. g2.translate(1280/2, 1024/2);
  43. BufferedImage subImg = pressStart.getSubimage(x, y, 49, 26);
  44. g2.drawImage(subImg, varx - 26*5, 0 - 20*5, 49*5, 26*5, null);
  45. BufferedImage subImg2 = colorStrike;
  46. g2.drawImage(subImg2, 0 -27*8 , 0 -300, 54*8, 18*8, null);
  47. varx+=0;
  48. Font textFont = new Font("OCR A Extended", Font.BOLD, 15);
  49. g2.setFont(textFont);
  50. g2.setColor(Color.WHITE);
  51. g2.drawString("Copyright 2015 by Daniel Compagner", -180, 500);
  52. }
  53. @Override
  54. public void buttonPressed(ButtonEvent e) {
  55. switch(e.getButton().getButtonID()){
  56. case 0:
  57. gsm.next();
  58. break;
  59. }
  60. }
  61. @Override
  62. public void buttonReleased(ButtonEvent e) {
  63. }
  64. @Override
  65. public void onJoystickMoved(JoystickEvent e) {
  66. // TODO Auto-generated method stub
  67. }
  68. }