Advertisement
Guest User

Untitled

a guest
Feb 13th, 2016
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.39 KB | None | 0 0
  1. package mygame;
  2.  
  3. import java.awt.Color;
  4. import java.awt.Font;
  5. import java.awt.Graphics;
  6. import java.awt.event.KeyEvent;
  7.  
  8. import javax.swing.JPanel;
  9.  
  10. import mygame.GamePanel;
  11. import mygame.Main;
  12.  
  13. @SuppressWarnings("serial")
  14. public class MenuPause extends JPanel {
  15.  
  16. private String[] options = {"Start", "Option", "Quit"};
  17. private int currentSelection = 0;
  18.  
  19.  
  20. public void draw(Graphics g) {
  21.  
  22. g.setColor(new Color(50,150,200));
  23. g.fillRect(0,0, GamePanel.WIDTH,GamePanel.HEIGHT);
  24. for(int i = 0; i< options.length; i++){
  25. if(i == currentSelection) {
  26. g.setColor(Color.GREEN);
  27. }else{
  28. g.setColor(Color.BLACK);
  29. }
  30. //g.drawLine(GamePanel.WIDTH / 2, 0,GamePanel.WIDTH / 2, GamePanel.HEIGHT);
  31. g.setFont(new Font("Arial", Font.PLAIN, 84));
  32. g.drawString(options[i], GamePanel.WIDTH / 2 - 90, 200 + i * 150);
  33.  
  34.  
  35. }
  36.  
  37. }
  38.  
  39. public void keyPressed(int k) {
  40. if(k == KeyEvent.VK_DOWN){
  41. currentSelection++;
  42. if(currentSelection >= options.length){
  43. currentSelection = 0;
  44. }
  45. }else if(k == KeyEvent.VK_UP){
  46. currentSelection--;
  47. if(currentSelection < 0){
  48. currentSelection = options.length - 1;
  49.  
  50. }
  51. }
  52. if(k == KeyEvent.VK_ENTER){
  53. if(currentSelection == 0){new Scene();
  54. }else if(currentSelection == 1){
  55. }else if(currentSelection == 2){System.exit(0);}
  56. }
  57. }
  58.  
  59. public void keyReleased(int k) {
  60.  
  61. }
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement