Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2014
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.44 KB | None | 0 0
  1. public class spaceFrame extends JFrame
  2. {
  3.     private static final long serialVersionUID = 1L;
  4.    
  5.     fullScreen screen = new fullScreen();
  6.     Images img = new Images();
  7.     startMenu menu = new startMenu();
  8.     Controller control = new Controller();
  9.     mouseMotionInput mouse = new mouseMotionInput();
  10.    
  11.     private int shipX = 350;
  12.     private int shipY = 450;
  13.    
  14.     public spaceFrame()
  15.     {
  16.         DisplayMode dm = new DisplayMode(800, 600, 16, DisplayMode.REFRESH_RATE_UNKNOWN);
  17.         run(dm);
  18.        
  19.         img.loadpics();
  20.        
  21.         this.addMouseListener(new mouseInput());
  22.         this.addMouseMotionListener(mouse);
  23.         this.addKeyListener(new keyInput());
  24.     }
  25.    
  26.     public void run(DisplayMode dm)
  27.     {
  28.         setBackground(Color.BLACK);
  29.         setForeground(Color.BLACK);
  30.         setFont(new Font("Arial", Font.PLAIN, 20));
  31.        
  32.         screen.setFullScreen(dm, this);
  33.     }
  34.    
  35.     public void paint(Graphics g)
  36.     {
  37.         /*
  38.         if(!menu.isPlayClicked()) // menu
  39.         {
  40.             menu.draw(g);
  41.             repaint();
  42.             return;
  43.         }*/
  44.        
  45.         g.drawImage(img.getBackground(), 0, 0, null); // background
  46.         g.drawImage(img.getSpaceShip(), mouse.getMouseX()-58, mouse.getMouseY()-38, null); // ship
  47.        
  48.         control.startingEnemies(g);
  49.         control.draw(g);
  50.        
  51.         if(shipX < -100)
  52.             shipX = 800;
  53.         if(shipX > 800)            // bounds
  54.             shipX = -100;
  55.         if(shipY < -100)
  56.             shipY = 600;
  57.         if(shipY > 600)
  58.             shipY = -100;
  59.        
  60.         try {
  61.             Thread.sleep(50);
  62.             repaint();
  63.         } catch (InterruptedException e) {
  64.             e.printStackTrace();
  65.         }
  66.     }
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement