Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import javax.swing.*;
- import java.io.*;
- import java.awt.*;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- import java.awt.event.KeyEvent;
- import java.awt.event.KeyListener;
- import java.awt.image.*;
- import javax.imageio.*;
- public class board extends JPanel implements KeyListener,ActionListener {
- public BufferedImage pacboard, bashful,speedy,shadow,greenpacman,pacman,pokey,blueghostx;
- static int rowNum = 0, colNum = 0;
- public board () {
- //pac man board is 27*29
- //there are four master pellets and 240 normal pellets
- //1=pellets
- // 0=places where pac cant go
- //2=supper pellet
- //3=teloportation area
- int board[][]={{0,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1,1,1,0},
- {0,1,0,0,0,0,1,0,0,0,0,0,1,0,1,0,0,0,0,0,1,0,0,0,0,1,0},
- {0,2,0,0,0,0,1,0,0,0,0,0,1,0,1,0,0,0,0,0,1,0,0,0,0,2,0},
- {0,1,0,0,0,0,1,0,0,0,0,0,1,0,1,0,0,0,0,0,1,0,0,0,0,1,0},
- {0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0},
- {0,1,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,0,1,0,0,1,0,0,0,0,1,0}};
- try{
- pacboard= ImageIO.read(new File("C:\\Users\\starw\\Desktop\\Santhosh\\Pac image\\pac board.jpg"));
- pacman= ImageIO.read(new File("C:\\Users\\starw\\Desktop\\Santhosh\\Pac image\\pacman.png"));
- greenpacman = ImageIO.read(new File("C:\\Users\\starw\\Desktop\\Santhosh\\Pac image\\green pacman.png"));
- shadow = ImageIO.read(new File("C:\\Users\\starw\\Desktop\\Santhosh\\Pac image\\shadow.png"));
- speedy = ImageIO.read(new File("C:\\Users\\starw\\Desktop\\Santhosh\\Pac image\\speedy.png"));
- bashful = ImageIO.read(new File("C:\\Users\\starw\\Desktop\\Santhosh\\Pac image\\bashful.png"));
- pokey = ImageIO.read(new File("C:\\Users\\starw\\Desktop\\Santhosh\\Pac image\\pokey.png"));
- }
- catch (IOException e){
- System.out.println("You do not have the way");
- }
- }
- public void paintComponent(Graphics g) {
- g.drawImage(pacboard, 0, 0, null);
- g.drawImage(pacman, 300, 437, null);
- g.drawImage(greenpacman, 390, 437, null);
- g.drawImage(shadow, 350, 280, null);
- g.drawImage(speedy, 350, 360, null);
- g.drawImage(bashful, 300, 360, null);
- g.drawImage(pokey, 400, 360, null);
- // g.setColor(Color.blue);
- // g.fillRect(68,69,80,52);//this is the far left block
- // g.fillRect(198,69,105,52);//this is the 2 far left block
- // g.fillRect(590,69,80,52);//this is the far left block
- // g.fillRect(434,69,105,52);//this is the 2 far right
- repaint();
- }
- public void actionPerformed(ActionEvent arg0) {
- }
- public void keyPressed(KeyEvent e) {
- if (e.getKeyCode()==KeyEvent.VK_UP) {
- }
- }
- public void keyReleased(KeyEvent arg0) {
- }
- public void keyTyped(KeyEvent arg0) {
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement