SHARE
TWEET

Untitled

a guest Jun 18th, 2019 63 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. private void start() {
  2.  
  3. /*initialized game elements here */
  4.  
  5.         frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  6.         frame.setResizable(false);
  7.         JPanel panel = new JPanel() {
  8.             @Override
  9.             public void paintComponent(Graphics g) {
  10.                 /* Drew objects here */
  11.         };
  12.  
  13.         panel.setPreferredSize(new Dimension(800,600));
  14.         frame.add(panel);
  15.         frame.pack();
  16.         frame.setVisible(true);
  17.         mapKeyStrokesToActions(panel);
  18.  
  19.         /* Timer */
  20.         timer = new Timer(10, new ActionListener() {
  21.             @Override
  22.             public void actionPerformed(ActionEvent arg0) {
  23.                 updateGame();
  24.                 panel.repaint();
  25.             }
  26.         });
  27.         timer.start();
  28.     }
  29.      
  30. if(gameOver()) {
  31.             frame.getContentPane().removeAll();
  32.             runner.start();
  33.         }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top