Advertisement
Guest User

board

a guest
Jan 22nd, 2018
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.67 KB | None | 0 0
  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,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},
  24. {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},
  25. {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},
  26. {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},
  27. {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},
  28. {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}};
  29. try{
  30. pacboard= ImageIO.read(new File("C:\\Users\\starw\\Desktop\\Santhosh\\Pac image\\pac board.jpg"));
  31. pacman= ImageIO.read(new File("C:\\Users\\starw\\Desktop\\Santhosh\\Pac image\\pacman.png"));
  32. greenpacman = ImageIO.read(new File("C:\\Users\\starw\\Desktop\\Santhosh\\Pac image\\green pacman.png"));
  33. shadow = ImageIO.read(new File("C:\\Users\\starw\\Desktop\\Santhosh\\Pac image\\shadow.png"));
  34. speedy = ImageIO.read(new File("C:\\Users\\starw\\Desktop\\Santhosh\\Pac image\\speedy.png"));
  35. bashful = ImageIO.read(new File("C:\\Users\\starw\\Desktop\\Santhosh\\Pac image\\bashful.png"));
  36. pokey = ImageIO.read(new File("C:\\Users\\starw\\Desktop\\Santhosh\\Pac image\\pokey.png"));
  37.  
  38. }
  39. catch (IOException e){
  40. System.out.println("You do not have the way");
  41. }
  42. }
  43. public void paintComponent(Graphics g) {
  44. g.drawImage(pacboard, 0, 0, null);
  45. g.drawImage(pacman, 300, 437, null);
  46. g.drawImage(greenpacman, 390, 437, null);
  47. g.drawImage(shadow, 350, 280, null);
  48. g.drawImage(speedy, 350, 360, null);
  49. g.drawImage(bashful, 300, 360, null);
  50. g.drawImage(pokey, 400, 360, null);
  51. // g.setColor(Color.blue);
  52. // g.fillRect(68,69,80,52);//this is the far left block
  53. // g.fillRect(198,69,105,52);//this is the 2 far left block
  54. // g.fillRect(590,69,80,52);//this is the far left block
  55. // g.fillRect(434,69,105,52);//this is the 2 far right
  56. repaint();
  57. }
  58. public void actionPerformed(ActionEvent arg0) {
  59. }
  60. public void keyPressed(KeyEvent e) {
  61. if (e.getKeyCode()==KeyEvent.VK_UP) {
  62.  
  63. }
  64. }
  65. public void keyReleased(KeyEvent arg0) {
  66. }
  67. public void keyTyped(KeyEvent arg0) {
  68. }
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement