Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.*;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- import java.awt.event.KeyAdapter;
- import java.awt.event.KeyEvent;
- import javax.swing.*;
- public class Board extends JPanel implements ActionListener {
- Ball b;
- Image back,ground,groundOv,grass,loading;
- Timer time;
- public Board(){
- b = new Ball();
- addKeyListener(new AL());
- setFocusable(true);
- time = new Timer(5, this);
- time.start();
- }
- public void actionPerformed(ActionEvent e){
- b.move();
- repaint();
- }
- public void paint(Graphics g){
- Graphics2D g2d = (Graphics2D) g;
- super.paint(g);
- g2d.drawImage(b.getImage(), b.getX(), b.getY(), null);
- }
- private class AL extends KeyAdapter{
- public void keyPressed(KeyEvent e){
- b.keyPressed(e);
- }
- public void keyReleased(KeyEvent e){
- b.keyReleased(e);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement