Advertisement
Guest User

skeleton3

a guest
Apr 14th, 2010
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.63 KB | None | 0 0
  1. import java.awt.Graphics;
  2. import java.awt.Graphics2D;
  3. import java.awt.GraphicsDevice;
  4. import java.awt.Toolkit;
  5. import java.awt.event.ActionEvent;
  6. import java.awt.event.ActionListener;
  7. import java.awt.event.KeyAdapter;
  8. import java.awt.event.KeyEvent;
  9.  
  10. import javax.swing.JFrame;
  11. import javax.swing.JPanel;
  12. import javax.swing.Timer;
  13.  
  14. public class Main extends JFrame
  15. {
  16.     private static final long serialVersionUID = 1L;
  17.    
  18.     private final int WIDTH = 1000;
  19.     private final int HEIGHT = 550;
  20.     private String title = "Maple Story";
  21.     GraphicsDevice device;
  22.    
  23.     public Main()
  24.     {
  25.         add(new Board(WIDTH, HEIGHT));
  26.        
  27.         setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  28.         setSize(WIDTH,HEIGHT);
  29.         setLocationRelativeTo(null);
  30.         setTitle(title);
  31.         setResizable(false);
  32.         setVisible(true);
  33.     }
  34.    
  35.     public static void main(String [] args)
  36.     {
  37.         new Main();
  38.     }
  39.    
  40.     public class Board extends JPanel implements ActionListener
  41.     {
  42.         private static final long serialVersionUID = 1L;
  43.        
  44.         private int WIDTH;
  45.         private int HEIGHT;
  46.        
  47.         private Timer timer;
  48.        
  49.         private final int SPEED = 5;
  50.        
  51.         public Board(int width, int height)
  52.         {
  53.             this.WIDTH = width;
  54.             this.HEIGHT = height;
  55.            
  56.             addKeyListener(new TAdapter());
  57.             setFocusable(true);
  58.            
  59.             setup();
  60.            
  61.             setDoubleBuffered(true);
  62.             timer = new Timer(SPEED, this);
  63.             timer.start();
  64.         }
  65.        
  66.         public void actionPerformed(ActionEvent e)
  67.         {
  68.             update();
  69.             repaint();
  70.         }
  71.         /*
  72.          * Initialise all of your Objects in here
  73.          */
  74.         public void setup()
  75.         {
  76.            
  77.         }
  78.        
  79.         public void paint(Graphics g)
  80.         {
  81.             super.paint(g);
  82.  
  83.             Graphics2D g2d = (Graphics2D)g;
  84.            
  85.             /*
  86.              * START PAINTING
  87.              * START PAINTING
  88.              * START PAINTING
  89.              * START PAINTING
  90.              * START PAINTING
  91.              * START PAINTING
  92.              * START PAINTING
  93.              */
  94.            
  95.            
  96.            
  97.             /*
  98.              * STOP PAINTING
  99.              * STOP PAINTING
  100.              * STOP PAINTING
  101.              * STOP PAINTING
  102.              * STOP PAINTING
  103.              * STOP PAINTING
  104.              * STOP PAINTING
  105.              */
  106.            
  107.             Toolkit.getDefaultToolkit().sync();
  108.             g.dispose();
  109.         }
  110.         /*
  111.          * Update all of the x and y coordinates in here
  112.          */
  113.         public void update()
  114.         {
  115.            
  116.         }
  117.        
  118.         private class TAdapter extends KeyAdapter
  119.         {
  120.             public void keyReleased(KeyEvent e)
  121.             {
  122.                 if(e.getKeyCode()==27)
  123.                 {
  124.                     System.exit(0);
  125.                 }
  126.             }
  127.  
  128.             public void keyPressed(KeyEvent e)
  129.             {
  130.  
  131.             }
  132.         }
  133.     }
  134. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement