daily pastebin goal
57%
SHARE
TWEET

board

a guest Jan 22nd, 2018 48 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import javax.swing.*;
  2.  
  3. import java.io.*;
  4. import java.awt.*;
  5. import java.awt.event.ActionEvent;
  6. import java.awt.event.ActionListener;
  7. import java.awt.event.KeyEvent;
  8. import java.awt.event.KeyListener;
  9. import java.awt.image.*;
  10.  
  11. import javax.imageio.*;
  12.  
  13. public class board extends JPanel implements KeyListener,ActionListener {
  14.     public BufferedImage pacboard, bashful,speedy,shadow,greenpacman,pacman,pokey,blueghostx;
  15.     static int rowNum = 0, colNum = 0;
  16.     public board () {  
  17.         //pac man board is 27*29
  18.         //there are four master pellets and 240 normal pellets
  19.         //1=pellets
  20.         //  0=places where pac cant go
  21.         //2=supper pellet
  22.         //3=teloportation  area        
  23.         int board[][]={{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
  24.                 {0,1,1,1,1,1,1,1,1,1,1,1,1,0,0,1,1,1,1,1,1,1,1,1,1,1,1,0},
  25.                 {0,1,0,0,0,0,1,0,0,0,0,0,1,0,0,1,0,0,0,0,0,1,0,0,0,0,1,0},
  26.                 {0,1,0,0,0,0,1,0,0,0,0,0,1,0,0,1,0,0,0,0,0,1,0,0,0,0,1,0},
  27.                 {0,1,0,0,0,0,1,0,0,0,0,0,1,0,0,1,0,0,0,0,0,1,0,0,0,0,1,0},
  28.                 {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,1,0},
  29.                 {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},
  30.                 {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},
  31.                 {0,1,1,1,1,1,1,0,0,1,1,1,1,0,0,1,1,1,1,0,0,1,1,1,1,1,1,0},
  32.                 {0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0},
  33.                 {0,0,0,0,0,0,1,0,0,1,1,1,1,1,1,1,1,1,1,0,0,1,0,0,0,0,0,0},
  34.                 {0,0,0,0,0,0,1,0,0,1,0,0,0,2,2,0,0,0,1,0,0,1,0,0,0,0,0,0},
  35.                 {0,0,0,0,0,0,1,1,1,1,0,0,2,2,2,2,0,0,1,1,1,1,0,0,0,0,0,0},
  36.                 {0,0,0,0,0,0,1,0,0,1,0,0,2,2,2,2,0,0,1,0,0,1,0,0,0,0,0,0},
  37.                 {0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0},
  38.                 {0,0,0,0,0,0,1,0,0,1,1,1,1,1,1,1,1,1,1,0,0,1,0,0,0,0,0,0},
  39.                 {0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0},
  40.                 {0,1,1,1,1,1,1,1,1,1,1,1,1,0,0,1,1,1,1,1,1,1,1,1,1,1,1,0},
  41.                 {0,1,0,0,0,0,1,0,0,0,0,0,1,0,0,1,0,0,0,0,0,1,0,0,0,0,1,0},
  42.                 {0,1,0,0,0,0,1,0,0,0,0,0,1,0,0,1,0,0,0,0,0,1,0,0,0,0,1,0},
  43.                 {0,1,1,1,0,0,1,1,1,1,1,1,1,5,1,1,1,1,1,1,1,1,0,0,1,1,1,0},
  44.                 {0,0,0,1,0,0,1,0,0,1,0,0,0,0,0,0,0,0,1,0,0,1,0,0,1,0,0,0},
  45.                 {0,0,0,1,0,0,1,0,0,1,0,0,0,0,0,0,0,0,1,0,0,1,0,0,1,0,0,0},
  46.                 {0,1,1,1,1,1,1,0,0,1,1,1,1,0,0,1,1,1,1,0,0,1,1,1,1,1,1,0},
  47.                 {0,1,0,0,0,0,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,1,0},
  48.                 {0,1,0,0,0,0,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,1,0},
  49.                 {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,1,0},
  50.                 {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}};
  51.         try{
  52.             pacboard= ImageIO.read(new File("C:\\Users\\starw\\Desktop\\Santhosh\\Pac image\\pac board.jpg"));
  53.             pacman= ImageIO.read(new File("C:\\Users\\starw\\Desktop\\Santhosh\\Pac image\\pacman.png"));
  54.             greenpacman = ImageIO.read(new File("C:\\Users\\starw\\Desktop\\Santhosh\\Pac image\\green pacman.png"));
  55.             shadow = ImageIO.read(new File("C:\\Users\\starw\\Desktop\\Santhosh\\Pac image\\shadow.png"));
  56.             speedy = ImageIO.read(new File("C:\\Users\\starw\\Desktop\\Santhosh\\Pac image\\speedy.png")); 
  57.             bashful = ImageIO.read(new File("C:\\Users\\starw\\Desktop\\Santhosh\\Pac image\\bashful.png"));
  58.             pokey = ImageIO.read(new File("C:\\Users\\starw\\Desktop\\Santhosh\\Pac image\\pokey.png"));
  59.         }
  60.         catch (IOException e){
  61.             System.out.println("You do not have the way");
  62.         }
  63.     }
  64.     public void paintComponent(Graphics g) {
  65.         g.drawImage(pacboard, 0, 0, null);
  66.         g.drawImage(pacman, 300, 437, null);
  67.         g.drawImage(greenpacman, 390, 437, null);
  68.         g.drawImage(shadow, 350, 280, null);
  69.         g.drawImage(speedy, 350, 360, null);
  70.         g.drawImage(bashful, 300, 360, null);
  71.         g.drawImage(pokey, 400, 360, null);
  72. //      g.setColor(Color.blue);
  73. //      g.fillRect(68,69,80,52);//this is the far left block
  74. //      g.fillRect(198,69,105,52);//this is the 2 far left block
  75. //      g.fillRect(590,69,80,52);//this is the far left block
  76. //      g.fillRect(434,69,105,52);//this is the 2 far right
  77.         repaint();
  78.     }
  79.     public void actionPerformed(ActionEvent arg0) {
  80.     }
  81.     public void keyPressed(KeyEvent e) {
  82.         if (e.getKeyCode()==KeyEvent.VK_UP) {
  83.            
  84.         }
  85.     }
  86.     public void keyReleased(KeyEvent arg0) {
  87.     }
  88.     public void keyTyped(KeyEvent arg0) {
  89.     }
  90. }
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