Advertisement
Guest User

Untitled

a guest
Jan 8th, 2017
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.26 KB | None | 0 0
  1. import java.awt.event.ActionEvent;
  2. import java.awt.event.ActionListener;
  3. import java.awt.event.KeyEvent;
  4. import java.awt.event.KeyListener;
  5. import java.awt.*;
  6. import javax.swing.*;
  7.  
  8.  
  9. @SuppressWarnings({ "unused", "serial" })
  10. public class FinalBlowzXC extends JFrame implements KeyListener{
  11.  
  12. public static JPanel game=new JPanel();
  13. public static JPanel mainmenu=new JPanel(null);
  14. public static JPanel loginpanel=new JPanel(null);
  15. public static JPanel tutorial=new JPanel(null);
  16. public static JPanel registration=new JPanel(null);
  17. public static JPanel town_map=new JPanel(null);
  18. public static JPanel level1=new JPanel(null);
  19. public JTextField username= new JTextField("Username");
  20. public JTextField password=new JTextField("Password");
  21. public JLabel bglogin=new JLabel();
  22. public JLabel character=new JLabel();
  23. public JButton log_in=new JButton();
  24. public JButton register=new JButton();
  25. CardLayout page= new CardLayout();
  26. public String level="";
  27. public int charx=350;
  28. public int chary=435;
  29.  
  30. public static void main(String []args)
  31. {
  32. new FinalBlowzXC().setVisible(true);
  33. }
  34.  
  35. public FinalBlowzXC()
  36. {
  37. super("Final Blowz Xchanged");
  38. setSize(640,510);
  39. setResizable(false);
  40. setDefaultCloseOperation(EXIT_ON_CLOSE);
  41.  
  42. addKeyListener(this);
  43. setFocusable(true);
  44.  
  45. game.setLayout(page);
  46. game.add(mainmenu, "1");
  47. game.add(loginpanel, "2");
  48. game.add(tutorial, "3");
  49. game.add(registration, "4");
  50. game.add(town_map, "5");
  51. game.add(level1, "l1");
  52. add(game);
  53. opening();
  54. }
  55.  
  56. public void opening()
  57. {
  58. page.show(game, "1");
  59. JLabel bgmainmenu;
  60. JButton start;
  61. JButton exit;
  62. bgmainmenu = new JLabel();
  63. start = new JButton();
  64. exit = new JButton();
  65.  
  66. bgmainmenu.setIcon(new ImageIcon(getClass().getResource("/FF-XV.jpg")));
  67. bgmainmenu.setBounds(0,0,640,480);
  68. mainmenu.add(bgmainmenu);
  69. mainmenu.add(start);
  70. start.setBounds(280, 360, 70, 20);
  71. start.setBorder(null);
  72. start.setBorderPainted(false);
  73. start.setContentAreaFilled(false);
  74. start.setOpaque(false);
  75. start.addActionListener(new Start());
  76. exit.setBounds(280, 385, 70, 20);
  77. mainmenu.add(exit);
  78. exit.setBorder(null);
  79. exit.setBorderPainted(false);
  80. exit.setContentAreaFilled(false);
  81. exit.setOpaque(false);
  82. exit.addActionListener(new ActionListener() {
  83. public void actionPerformed(ActionEvent e)
  84. {
  85. System.exit(0);
  86. }
  87. });
  88. }
  89.  
  90.  
  91. class Start implements ActionListener{
  92.  
  93. public void actionPerformed(ActionEvent e) {
  94. login();
  95.  
  96. }
  97.  
  98. }
  99.  
  100. public void login()
  101. {
  102. page.show(game, "2");
  103.  
  104. bglogin.setIcon(new ImageIcon(getClass().getResource("/FF-XV Login.jpg")));
  105. bglogin.setBounds(0, 0, 640, 480);
  106.  
  107.  
  108. username.setBounds(300, 285, 85, 15);
  109. username.setBorder(null);
  110. username.setForeground(Color.WHITE);
  111. username.setOpaque(false);
  112.  
  113. password.setBounds(300, 310, 85, 20);
  114. password.setBorder(null);
  115. password.setForeground(Color.WHITE);
  116. password.setOpaque(false);
  117.  
  118. log_in.setBounds(280, 335, 50, 45);
  119. log_in.setBorder(null);
  120. log_in.setBorderPainted(false);
  121. log_in.setContentAreaFilled(false);
  122. log_in.setOpaque(false);
  123. log_in.addActionListener(new Log_in());
  124.  
  125. register.setBounds(335, 335, 55, 45);
  126. register.setBorder(null);
  127. register.setBorderPainted(false);
  128. register.setContentAreaFilled(false);
  129. register.setOpaque(false);
  130. register.addActionListener(new Register());
  131.  
  132. loginpanel.add(username);
  133. loginpanel.add(password);
  134. loginpanel.add(bglogin);
  135. loginpanel.add(log_in);
  136. loginpanel.add(register);
  137. }
  138.  
  139. class Log_in implements ActionListener{
  140.  
  141. public void actionPerformed(ActionEvent e)
  142. {
  143. Tutorial();
  144.  
  145. }
  146.  
  147. }
  148.  
  149. class Register implements ActionListener{
  150.  
  151. public void actionPerformed(ActionEvent e)
  152. {
  153. page.show(game, "4");
  154. }
  155. }
  156.  
  157. public void Tutorial()
  158. {
  159. page.show(game, "3");
  160. JLabel bgtutorial=new JLabel();
  161. JLabel animeforward=new JLabel();
  162. JLabel animeright=new JLabel();
  163. JLabel animeleft=new JLabel();
  164. JButton next=new JButton();
  165. JLabel animebackward=new JLabel();
  166. bgtutorial.setIcon(new ImageIcon(getClass().getResource("/FF-XV Tutorial.jpg")));
  167. bgtutorial.setBounds(0, 0, 640, 480);
  168. animeforward.setIcon(new ImageIcon(getClass().getResource("/walkanimofficialfront.gif")));
  169. animeforward.setBounds(115, 230, 30, 30);
  170. animeright.setIcon(new ImageIcon(getClass().getResource("/walkanimofficialright.gif")));
  171. animeright.setBounds(190, 315, 30, 30);
  172. animeleft.setIcon(new ImageIcon(getClass().getResource("/walkanimofficialleft.gif")));
  173. animeleft.setBounds(45, 315, 30, 30);
  174. animebackward.setIcon(new ImageIcon(getClass().getResource("/walkanimofficialback.gif")));
  175. animebackward.setBounds(115, 405, 30, 30);
  176. next.setBounds(530, 430, 100, 30);
  177. next.setBorder(null);
  178. next.setBorderPainted(false);
  179. next.setContentAreaFilled(false);
  180. next.setOpaque(false);
  181. next.addActionListener(new Next());
  182. tutorial.add(next);
  183. tutorial.add(animeright);
  184. tutorial.add(animeleft);
  185. tutorial.add(animebackward);
  186. tutorial.add(animeforward);
  187. tutorial.add(bgtutorial);
  188.  
  189. }
  190.  
  191. class Next implements ActionListener{
  192.  
  193. public void actionPerformed(ActionEvent e)
  194. {
  195. town();
  196. }
  197. }
  198.  
  199. public void town()
  200. {
  201. page.show(game, "5");
  202. JLabel map=new JLabel();
  203. map.setIcon(new ImageIcon(getClass().getResource("/FF-XV Town.jpg")));
  204. map.setBounds(0, 0, 640, 480);
  205. character.setIcon(new ImageIcon(getClass().getResource("/standfront.png")));
  206. character.setBounds(charx, chary, 30, 35);
  207. town_map.add(character);
  208. town_map.add(map);
  209. }
  210.  
  211. public void keyPressed(KeyEvent e) {
  212.  
  213. if(e.getKeyCode()==KeyEvent.VK_UP&&character.getY()!=0)
  214. {
  215. character.setIcon(new ImageIcon(getClass().getResource("/walkanimofficialfront.gif")));
  216. character.setLocation(character.getX(), character.getY()-5);
  217. }
  218.  
  219. else if(e.getKeyCode()==KeyEvent.VK_RIGHT&&character.getX()+30!=640)
  220. {
  221. character.setIcon(new ImageIcon(getClass().getResource("/walkanimofficialright.gif")));
  222. character.setLocation(character.getX()+5, character.getY());
  223. }
  224.  
  225. else if(e.getKeyCode()==KeyEvent.VK_LEFT&&character.getX()!=0)
  226. {
  227. character.setIcon(new ImageIcon(getClass().getResource("/walkanimofficialleft.gif")));
  228. character.setLocation(character.getX()-5, character.getY());
  229. }
  230.  
  231. else if(e.getKeyCode()==KeyEvent.VK_DOWN&&character.getY()+35!=480)
  232. {
  233. character.setIcon(new ImageIcon(getClass().getResource("/walkanimofficialback.gif")));
  234. character.setLocation(character.getX(), character.getY()+5);
  235. }
  236.  
  237. }
  238.  
  239.  
  240. public void keyReleased(KeyEvent e) {
  241.  
  242. }
  243.  
  244. public void keyTyped(KeyEvent e) {
  245.  
  246.  
  247. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement