Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.Graphics;
- import java.awt.Graphics2D;
- import java.awt.GraphicsDevice;
- import java.awt.Toolkit;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- import java.awt.event.KeyAdapter;
- import java.awt.event.KeyEvent;
- import javax.swing.JFrame;
- import javax.swing.JPanel;
- import javax.swing.Timer;
- public class Main extends JFrame
- {
- private static final long serialVersionUID = 1L;
- private final int WIDTH = 1000;
- private final int HEIGHT = 550;
- private String title = "Maple Story";
- GraphicsDevice device;
- public Main()
- {
- add(new Board(WIDTH, HEIGHT));
- setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- setSize(WIDTH,HEIGHT);
- setLocationRelativeTo(null);
- setTitle(title);
- setResizable(false);
- setVisible(true);
- }
- public static void main(String [] args)
- {
- new Main();
- }
- public class Board extends JPanel implements ActionListener
- {
- private static final long serialVersionUID = 1L;
- private int WIDTH;
- private int HEIGHT;
- private Timer timer;
- private final int SPEED = 5;
- public Board(int width, int height)
- {
- this.WIDTH = width;
- this.HEIGHT = height;
- addKeyListener(new TAdapter());
- setFocusable(true);
- setup();
- setDoubleBuffered(true);
- timer = new Timer(SPEED, this);
- timer.start();
- }
- public void actionPerformed(ActionEvent e)
- {
- update();
- repaint();
- }
- /*
- * Initialise all of your Objects in here
- */
- public void setup()
- {
- }
- public void paint(Graphics g)
- {
- super.paint(g);
- Graphics2D g2d = (Graphics2D)g;
- /*
- * START PAINTING
- * START PAINTING
- * START PAINTING
- * START PAINTING
- * START PAINTING
- * START PAINTING
- * START PAINTING
- */
- /*
- * STOP PAINTING
- * STOP PAINTING
- * STOP PAINTING
- * STOP PAINTING
- * STOP PAINTING
- * STOP PAINTING
- * STOP PAINTING
- */
- Toolkit.getDefaultToolkit().sync();
- g.dispose();
- }
- /*
- * Update all of the x and y coordinates in here
- */
- public void update()
- {
- }
- private class TAdapter extends KeyAdapter
- {
- public void keyReleased(KeyEvent e)
- {
- if(e.getKeyCode()==27)
- {
- System.exit(0);
- }
- }
- public void keyPressed(KeyEvent e)
- {
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement