Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package mygame;
- import java.awt.Color;
- import java.awt.Font;
- import java.awt.Graphics;
- import java.awt.event.KeyEvent;
- import javax.swing.JPanel;
- import mygame.GamePanel;
- import mygame.Main;
- @SuppressWarnings("serial")
- public class MenuPause extends JPanel {
- private String[] options = {"Start", "Option", "Quit"};
- private int currentSelection = 0;
- public void draw(Graphics g) {
- g.setColor(new Color(50,150,200));
- g.fillRect(0,0, GamePanel.WIDTH,GamePanel.HEIGHT);
- for(int i = 0; i< options.length; i++){
- if(i == currentSelection) {
- g.setColor(Color.GREEN);
- }else{
- g.setColor(Color.BLACK);
- }
- //g.drawLine(GamePanel.WIDTH / 2, 0,GamePanel.WIDTH / 2, GamePanel.HEIGHT);
- g.setFont(new Font("Arial", Font.PLAIN, 84));
- g.drawString(options[i], GamePanel.WIDTH / 2 - 90, 200 + i * 150);
- }
- }
- public void keyPressed(int k) {
- if(k == KeyEvent.VK_DOWN){
- currentSelection++;
- if(currentSelection >= options.length){
- currentSelection = 0;
- }
- }else if(k == KeyEvent.VK_UP){
- currentSelection--;
- if(currentSelection < 0){
- currentSelection = options.length - 1;
- }
- }
- if(k == KeyEvent.VK_ENTER){
- if(currentSelection == 0){new Scene();
- }else if(currentSelection == 1){
- }else if(currentSelection == 2){System.exit(0);}
- }
- }
- public void keyReleased(int k) {
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement