Advertisement
pastetumlum

Untitled

Jul 16th, 2018
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.82 KB | None | 0 0
  1. public class BoardPanel extends JPanel {
  2.     public void paint(Graphics g) {
  3.         super.paint(g);
  4.         for (int y = 0; y < 8; y++) {
  5.             for (int x = 0; x < 8; x++) {
  6.                 if (gameMap.getMap(x, y).equals("h")) {
  7.                     g.drawImage(gameImage.getHoney(), x * 50, y * 50, null);
  8.                 }
  9.                 if (gameMap.getMap(x, y).equals("g")) {
  10.                     g.drawImage(gameImage.getGrass(), x * 50, y * 50, null);
  11.                 }
  12.  
  13.                 if (gameMap.getMap(x, y).equals("r")) {
  14.                     g.drawImage(gameImage.getRock(), x * 50, y * 50, null);
  15.                 }
  16.                 if (gameMap.getMap(x, y).equals("q")) {
  17.                     g.drawImage(gameImage.getQuestion(), x * 50, y * 50, null);
  18.                 }
  19.             }
  20.         }
  21.         g.drawImage(gameImage.getBear(), bear.getTitleX() * 50, bear.getTitleY() * 50, null);
  22.     }
  23.     // vẽ lại map với toạ độ đã thay đổi
  24.     public void updateBoard() {
  25.         repaint();
  26.     }
  27.  
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement