Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 16 of 16

Thread: Boulderdash

  1. #1
    Junior Member
    Join Date
    Mar 2013
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy Boulderdash

    I was hoping anyone would help me out with this assignment I have for exams. its for a game named Boulder dash. This is what I need
    •Set up graphical user interface
    •Represent diamonds, dirt, empty space, locked exit, open exit, wall squares and player as objects
    •Provide a method for the gamer to move player, and for player to dig through dirt leaving empty space and to collect diamonds
    •Check for falling objects , and move them downwards on a timer
    •Track and display the number of diamonds collected
    •Track and display the number of steps taken.
    •Check for player being crushed, and re-set the level if this occurs
    •Identify when enough diamonds have been collected and open the exit
    •Load a new level when Rockford gets to the open exit


  2. #2
    Member angstrem's Avatar
    Join Date
    Mar 2013
    Location
    Ukraine
    Posts
    200
    My Mood
    Happy
    Thanks
    9
    Thanked 31 Times in 29 Posts

    Default Re: Boulderdash

    And where did you stuck? What have you tried?

  3. #3
    Member angstrem's Avatar
    Join Date
    Mar 2013
    Location
    Ukraine
    Posts
    200
    My Mood
    Happy
    Thanks
    9
    Thanked 31 Times in 29 Posts

    Default Re: Boulderdash

    Please, wrap your code into <code=java></code> (replace < and > with [ and ] respectively in order to preserve highlighting and formatting. It's difficult to read that big amount of code without formatting.

  4. #4
    Junior Member
    Join Date
    Mar 2013
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Boulderdash

    Hello guys I was wondering whats wrong with this code here https://github.com/cuervoslaugh/boulder_dash because when I run it, it just gives a black screen!

  5. #5
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    SW Missouri
    Posts
    20,105
    Thanks
    48
    Thanked 2,153 Times in 2,126 Posts

    Default Re: Boulderdash

    Please copy and paste here any code you are having problems with.
    Be sure to wrap your code with
    [code=java]
    <YOUR CODE HERE>
    [/code]
    to get highlighting and preserve formatting.
    If you don't understand my answer, don't ignore it, ask a question.

  6. #6
    Junior Member
    Join Date
    Mar 2013
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Boulderdash

    The game runs but it only a black screen. how can I fix it?

    class Amoeba extends Monster {
     
      public Amoeba(int x, int y, Sprite.Directions d) {
        super(x, y, d);
      }
     
      public void changeDirection() {}
     
    }


     
    import java.util.*;
    import java.awt.*;
    import javax.swing.*;
    import java.awt.event.*;
    import java.awt.geom.*;
    import javax.swing.Timer;
     
     
    public class BoulderDash extends JPanel
    {
        private final int WIDTH = 40, HEIGHT = 22;
        private Random rng = new Random();
        public int rx, ry; // player coordinates    
        public int level; // current level
        public int topX = 0, topY= 0, xIdeal= 0, yIdeal= 0;
        boolean playerAlive;    
        public enum Directions { LEFT, RIGHT, UP, DOWN }
        public ArrayList<Monster> monsters;
        public ArrayList<Sprite> movingSprites;
        public Player player = new Player();
        public GameUtils gu = new GameUtils();
     
        public GameUtils.Contents[][] field = new GameUtils.Contents[WIDTH][HEIGHT];
     
        BoulderDash()
        {
          field = gu.loadGame();
          int[] loc = gu.getPlayerLocation(field);
          rx = loc[0];
          ry = loc[1];
          player.setX(rx);
          player.setY(ry);
     
          monsters = monsterUp();
          new Timer(200, new ScreenTransform()).start();
          new Timer(200, new FallingObjectCheck()).start();
          new Timer(100, new MonsterMover()).start(); 
     
     
          this.addKeyListener(new MyKeyListener());
          this.setFocusable(true);
          this.requestFocus();
          this.setPreferredSize(new Dimension(500, 400));
          this.setBorder(BorderFactory.createEtchedBorder());
          this.setBackground(Color.BLACK);
        }
     
        private class ScreenTransform implements ActionListener {
          public void actionPerformed(ActionEvent ae){
           xIdeal = rx;
           yIdeal = ry;
           topX = (xIdeal - 10) * 10;
           topY = (yIdeal - 10) * 10;
           repaint();
          }
        }
     
        private class MonsterMover implements ActionListener {
          public void actionPerformed(ActionEvent ae) {
            monsterMove();
          }
        }
        private class FallingObjectCheck implements ActionListener {
          public void actionPerformed(ActionEvent ae){
            for(int j = 21; j >= 0; j--){ // y
              for(int i = 0; i < 38; i++) {  // x
                setFallingObject(i, j);
                moveFallingObject(i, j);
                repaint();
              }
            }
          }
     
          public void setFallingObject(int x, int y) 
          {
            switch(field[x][y])
            {
              case ROCK:
                if(field[x][y + 1] == GameUtils.Contents.EMPTY) { 
                  field[x][y] = GameUtils.Contents.FALLINGROCK;
                  break;
                }
                if(field[x - 1][y] == GameUtils.Contents.EMPTY &&
                   field[x - 1][y + 1] == GameUtils.Contents.EMPTY) {
                  field[x][y] = GameUtils.Contents.FALLINGROCK;
                  break;
                }
                if(field[x + 1][y] == GameUtils.Contents.EMPTY &&
                   field[x + 1][y + 1] == GameUtils.Contents.EMPTY) {
                  field[x][y] = GameUtils.Contents.FALLINGROCK;
                  break;
                }
                if(field[x][y] == GameUtils.Contents.FALLINGROCK && 
                   (field[x][y + 1] == GameUtils.Contents.DIRT) ||
                   (field[x][y + 1] == GameUtils.Contents.WALL)) field[x][y] = GameUtils.Contents.ROCK;
                if(field[x][y + 1] == GameUtils.Contents.BUTTERFLY) { goBoom(x, y + 1, GameUtils.Contents.BUTTERFLY);}
                if(field[x][y + 1] == GameUtils.Contents.FIREFLY) {goBoom(x, y + 1, GameUtils.Contents.FIREFLY);}
                break;
              case DIAMOND:
                if(field[x][y + 1] == GameUtils.Contents.EMPTY) {
                  field[x][y] = GameUtils.Contents.FALLINGDIAMOND;
                }
                if(field[x - 1][y] == GameUtils.Contents.EMPTY &&
                   field[x - 1][y + 1] == GameUtils.Contents.EMPTY) {
                  field[x][y] = GameUtils.Contents.FALLINGDIAMOND;
                  break;
                }
                if(field[x + 1][y] == GameUtils.Contents.EMPTY &&
                   field[x + 1][y + 1] == GameUtils.Contents.EMPTY) {
                  field[x][y] = GameUtils.Contents.FALLINGDIAMOND;
                  break;
                }
                break;
            }
          }
     
          private void goBoom(int x, int y, GameUtils.Contents contact) 
          {
            switch(contact) {
              case PLAYER:
                playerAlive = false;
                break;
              case BUTTERFLY:
                splode(x, y);
                repaint();
                break;
              case FIREFLY:
                splode(x, y);
                repaint();
                break;
            }
          }
     
          public void splode(int x, int y) {
            int rEdge = x + 1;
            int lEdge = x - 1;
            int top = y - 1;
            int bottom = y + 1;
            for(int j = top; j <= bottom; j++){
              for(int i = lEdge; i <= rEdge; i++) {
                if(canTransMutate(i, j)) field[i][j] = GameUtils.Contents.DIAMOND;
              }
            }
          }
     
          private boolean canTransMutate(int x, int y) {
            switch(field[x][y]) {
              case FIREFLY:
                return true;
              case BUTTERFLY:
                return true;
              case EMPTY:
                return true;
              default:
                return false;
            }
          }
     
     
          public void moveFallingObject(int x, int y)
          {
            switch(field[x][y])
            {
              case FALLINGROCK:
                if(field[x][y + 1] == GameUtils.Contents.PLAYER)
                {
                  player.alive = false;
                  field[x][y + 1] = GameUtils.Contents.EMPTY;
                  break;
                }
                if(field[x][y + 1] == GameUtils.Contents.EMPTY)
              {
                field[x][y + 1] = GameUtils.Contents.FALLINGROCK;
                field[x][y] = GameUtils.Contents.EMPTY;
                break;
              }
                if(field[x][y + 1] == GameUtils.Contents.BUTTERFLY)
                {
                  goBoom(x, y, GameUtils.Contents.BUTTERFLY);
                  break;
                }
                if(field[x][y + 1] == GameUtils.Contents.AMOEBA)
                {
                  //kill the amoeba
                  break;
                }
                if(field[x - 1][y + 1] == GameUtils.Contents.EMPTY) {
                  field[x - 1][y + 1] = GameUtils.Contents.FALLINGROCK;
                  field[x][y] = GameUtils.Contents.EMPTY;
                  break;
                }
                if(field[x + 1][y + 1] == GameUtils.Contents.EMPTY) {
                  field[x + 1][y + 1] = GameUtils.Contents.FALLINGROCK;
                  field[x][y] = GameUtils.Contents.EMPTY;
                  break;
                }
                field[x][y] = GameUtils.Contents.ROCK;
                break;
              case FALLINGDIAMOND:
                if(field[x][y + 1] == GameUtils.Contents.EMPTY){
                  field[x][y + 1] = GameUtils.Contents.DIAMOND;
                  field[x][y] = GameUtils.Contents.EMPTY;
                  break;
              }
            }
          }
        }
     
        private class MyKeyListener implements KeyListener {
          private int kc;      
          public void keyPressed(KeyEvent ke) {
            kc = ke.getKeyCode();
            if(player.alive) {
            switch(kc){
              case 37:
                movePlayer(Directions.LEFT);
                break;
              case 38:
                movePlayer(Directions.UP);
                break;
              case 39:
                movePlayer(Directions.RIGHT);
                break;
              case 40:
                movePlayer(Directions.DOWN);
                break;
              case 78:
                if(level == 10) level = 0;
                nextLevel();
                break;
            }
            }
          }
          public void keyReleased(KeyEvent ke) {};
          public void keyTyped(KeyEvent ke) {};
      }
     
        public boolean isEmpty(int x, int y) {
          if(field[x][y] == GameUtils.Contents.EMPTY) return true;
          return false;
        }
     
        public void monsterMove() {
          if( monsters.size() > 0 ){
            for(Monster m : monsters) {
              Monster.Directions direction = m.getDirection();
              int mX = m.getX();
              int mY = m.getY();
              switch(direction) {
                case RANDOM:
                  Float chance = rng.nextFloat();
                  if(chance < 0.05) {
                    switch(rng.nextInt(4)) {
                      case 0:
                        if(field[mX - 1][mY] == GameUtils.Contents.EMPTY) {
                        field[mX - 1][mY] = GameUtils.Contents.AMOEBA;
                        break;
                      }
                      case 1:
                        if(field[mX + 1][mY] == GameUtils.Contents.EMPTY){
                        field[mX + 1][mY] = GameUtils.Contents.AMOEBA;
                        break;
                      }
                      case 2:
                        if(field[mX][mY - 1] == GameUtils.Contents.EMPTY){
                        field[mX][mY - 1] = GameUtils.Contents.AMOEBA;
                        break;
                      }
                      case 3:
                        if(field[mX][mY + 1] == GameUtils.Contents.EMPTY){
                        field[mX][mY + 1] = GameUtils.Contents.AMOEBA;
                        break;
                      }
                    }
     
                  }
                  break;
                case LEFT:
                  //code to go left
                  if(hasPlayer(mX - 1, mY)) {
                    player.alive = false;
                    break;}
                  if(isEmpty(mX - 1, mY)) {
                    field[mX - 1][mY] = field[mX][mY];
                    field[mX][mY] = GameUtils.Contents.EMPTY;
                    m.setX(mX - 1);
                } else { m.changeDirection(); }
                  break;
                case RIGHT:
                  //code to go right
                  if(hasPlayer(mX + 1, mY)) {
                  player.alive = false;
                  break;
                }
                  if(isEmpty(mX + 1, mY)) {              
                    field[mX + 1][mY] = field[mX][mY];
                    field[mX][mY] = GameUtils.Contents.EMPTY;
                    m.setX(mX + 1);
                } else { m.changeDirection(); }
                  break;
                case UP:
                  //code to go up
                  if(hasPlayer(mX, mY - 1)) {
                  player.alive = false;
                  break;
                }
                  if(isEmpty(mX, mY - 1)) {             
                    field[mX][mY - 1] = field[mX][mY];
                    field[mX][mY] = GameUtils.Contents.EMPTY;
                    m.setY(mY - 1);
                } else { m.changeDirection(); }                            
                  break;
                case DOWN:
                  //code to go down
                  if(hasPlayer(mX, mY + 1)) {
                  player.alive = false;
                  break;
                }
                  if(isEmpty(mX, mY +1)) {              
                    field[mX][mY + 1] = field[mX][mY];
                    field[mX][mY] = GameUtils.Contents.EMPTY;
                    m.setY(mY + 1);
                }  else { m. changeDirection(); }                   
                  break;
              }
            }
          }
        }
     
        private boolean hasPlayer(int x, int y) {
          if(field[x][y] == GameUtils.Contents.PLAYER) return true;
          return false;
        }
     
     
        private void checkExit(Directions direction){
          switch(direction){
            case LEFT:
              if( hasLevelExit(rx - 1, ry) && player.diamonds >= gu.diamondsNeeded){ nextLevel();}
              break;
            case RIGHT:
              if(hasLevelExit(rx + 1, ry) && player.diamonds >= gu.diamondsNeeded) { nextLevel(); }
              break;
            case UP:
              if(hasLevelExit(rx, ry - 1) && player.diamonds >= gu.diamondsNeeded) { nextLevel(); }
              break;
            case DOWN:
              if(hasLevelExit(rx, ry + 1) && player.diamonds >= gu.diamondsNeeded) { nextLevel(); }
              break;
          }
        }
     
        private void movePlayer(Directions direction)
        {
          switch(direction){
            case DOWN:
              checkExit(Directions.DOWN);
              if(!hasContact(Directions.DOWN)){
                if(field[rx][ry +1] == GameUtils.Contents.DIAMOND) { 
                  player.increasePoints(10);
                  gu.diamondsNeeded -= 1;
                }
              field[rx][ry + 1] = GameUtils.Contents.PLAYER;
              field[rx][ry] = GameUtils.Contents.EMPTY;
              ry += 1;
              repaint();
              }
              break;
            case UP:
              checkExit(Directions.UP);
              if(!hasContact(Directions.UP)){
                if(field[rx][ry - 1] == GameUtils.Contents.DIAMOND) { 
                  player.increasePoints(10);
                  gu.diamondsNeeded -= 1;
                }            
              field[rx][ry - 1] = GameUtils.Contents.PLAYER;
              field[rx][ry] = GameUtils.Contents.EMPTY;
              ry -= 1;
              repaint();
              }
              break;
            case LEFT:
              checkExit(Directions.LEFT);
              moveRock(Directions.LEFT);
              if(!hasContact(Directions.LEFT)){
                if(field[rx - 1][ry] == GameUtils.Contents.DIAMOND) { 
                  player.increasePoints(10);
                  gu.diamondsNeeded -= 1;
                }            
                field[rx - 1][ry] = GameUtils.Contents.PLAYER;
                field[rx][ry] = GameUtils.Contents.EMPTY;
                rx -= 1;
                repaint();
              }
              break;
            case RIGHT:
              checkExit(Directions.RIGHT);
              moveRock(Directions.RIGHT);
              if(!hasContact(Directions.RIGHT)){
                if(field[rx + 1][ry] == GameUtils.Contents.DIAMOND) { 
                  player.increasePoints(10);
                  gu.diamondsNeeded -= 1;
                }            
              field[rx + 1][ry] = GameUtils.Contents.PLAYER;
              field[rx][ry] = GameUtils.Contents.EMPTY;
              rx += 1;
              repaint();
              }
              break;
          }
        }
     
        private boolean hasLevelExit(int x, int y){
         if(field[x][y] == GameUtils.Contents.EXIT) {
            return true;
          }
          return false;
        }
     
        public void nextLevel(){
          for(int i = 0; i < WIDTH; i++){
            for(int j = 0; j < HEIGHT; j++){
              field[i][j] = GameUtils.Contents.EMPTY;
            }
          }
          field = gu.increaseLevel(gu.level);
          int loc[] = gu.getPlayerLocation(field);
          rx = loc[0];
          ry = loc[1];
          player.diamonds = 0;
          this.monsters = monsterUp();
          repaint();
        }
     
     
        private void moveRock(Directions direction) 
        {
          switch(direction){
            case DOWN:
              if(field[rx][ry + 1] == GameUtils.Contents.ROCK && 
                 field[rx][ry + 2] == GameUtils.Contents.EMPTY) {
              field[rx][ry + 2] = GameUtils.Contents.ROCK;
              field[rx][ry + 1] = GameUtils.Contents.EMPTY;
            }
            break;
            case UP:
              break;
            case LEFT:
              if(field[rx - 1][ry] == GameUtils.Contents.ROCK &&
                 field[rx - 2][ry] == GameUtils.Contents.EMPTY) {
              field[rx - 2][ry] = GameUtils.Contents.ROCK;
              field[rx - 1][ry] = GameUtils.Contents.EMPTY;
            }
              break;
            case RIGHT:
              if(field[rx + 1][ry] == GameUtils.Contents.ROCK &&
                 field[rx + 2][ry] == GameUtils.Contents.EMPTY) {
              field[rx + 2][ry] = GameUtils.Contents.ROCK;
              field[rx + 1][ry] = GameUtils.Contents.EMPTY;
            }
              break;
          }
        }
     
        private boolean hasContact(Directions direction)
        {       
          switch(direction){
            case DOWN:
              if(field[rx][ry + 1] == GameUtils.Contents.EMPTY || 
                 field[rx][ry + 1] == GameUtils.Contents.DIRT ||
                 field[rx][ry + 1] == GameUtils.Contents.DIAMOND ||
                 field[rx][ry + 1] == GameUtils.Contents.FALLINGDIAMOND) { return false; }
              else {return true;}
            case UP:
              if(field[rx][ry - 1] == GameUtils.Contents.EMPTY || 
                 field[rx][ry - 1] == GameUtils.Contents.DIRT ||
                 field[rx][ry - 1] == GameUtils.Contents.DIAMOND||
                 field[rx][ry - 1] == GameUtils.Contents.FALLINGDIAMOND) { return false; }
              else {return true;}
            case LEFT:
              if(field[rx - 1][ry] == GameUtils.Contents.EMPTY || 
                 field[rx - 1][ry] == GameUtils.Contents.DIRT ||
                 field[rx - 1][ry] == GameUtils.Contents.DIAMOND|| 
                 field[rx - 1][ry] == GameUtils.Contents.FALLINGDIAMOND) { return false; }
              else {return true;}
            case RIGHT:
              if(field[rx + 1][ry] == GameUtils.Contents.EMPTY || 
                 field[rx + 1][ry] == GameUtils.Contents.DIRT ||
                 field[rx + 1][ry] == GameUtils.Contents.DIAMOND||
                 field[rx + 1][ry] == GameUtils.Contents.FALLINGDIAMOND) { return false; }
              else {return true;}
          }
          return true;
        }
     
        public void paintComponent(Graphics g)
        {
          super.paintComponent(g);
          Graphics2D g2 = (Graphics2D)g;
          g2.translate(-topX, -topY);
          for(int j = 0; j < HEIGHT; j++){
            for(int i = 0; i < WIDTH; i++){
              boolean isBoulder = false;
              switch(field[i][j]){
                case EMPTY:
                  g2.setColor(Color.black);
                  break;
                case DIRT:
                  g2.setColor(new Color(165, 42, 42));
                  break;
                case WALL:
                  g2.setColor(Color.gray);
                  break;
                case ROCK:
                  isBoulder = true;
                  g2.setColor(Color.pink);
                  break;
                case FALLINGROCK:
                  isBoulder = true;
                  g2.setColor(Color.pink);
                  break;
                case DIAMOND:
                  g2.setColor(Color.white);
                  break;
                case FALLINGDIAMOND:
                  g2.setColor(Color.white);
                  break;
                case AMOEBA:
                  g2.setColor(new Color(0, 100, 0));
                  break;
                case FIREFLY:
                  g2.setColor(Color.orange);
                  break;
                case BUTTERFLY:
                  g2.setColor(Color.yellow);
                  break;
                case EXIT:
                  g2.setColor(Color.blue);
                  break;
                case PLAYER:
                  int seconds;
                  Date date = new Date();
                  seconds = date.getSeconds();
                  if((seconds % 3 == 0) && (player.diamonds >= gu.diamondsNeeded)) {
                    g2.setColor(Color.red);
                  } else {
                    g2.setColor(Color.green); }
                  break;
              }
              if(isBoulder) { 
                g2.fill(new Ellipse2D.Double(i*20, j*20, 20, 20));
                isBoulder = false;
              }
              g2.fill(new Ellipse2D.Double(i*20, j*20, 20, 20));
            }
          }
          g2.translate(topX, topY);
        }
     
        public ArrayList<Monster> monsterUp(){
          ArrayList<Monster> ret = new ArrayList<Monster>();
     
          for(int x = 0; x < 38; x++) {
            for(int y = 0; y < 21; y++) {
              if(field[x][y] == GameUtils.Contents.FIREFLY) {
                Firefly f = new Firefly(x, y, Sprite.Directions.RIGHT);
                ret.add(f);
              }
              if(field[x][y] == GameUtils.Contents.BUTTERFLY){
                Butterfly b = new Butterfly(x, y, Sprite.Directions.LEFT);
                ret.add(b);
              }
              if(field[x][y] == GameUtils.Contents.AMOEBA) {
                Amoeba a = new Amoeba(x, y, Sprite.Directions.RANDOM);
                ret.add(a);
              }
            }
          }
          return ret;
        }
     
         public static void main(String[] args)
         {
           JFrame jf = new JFrame("CCPS 209 Final Project");
           jf.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
           jf.setLayout(new FlowLayout());
           final BoulderDash bd = new BoulderDash();
           jf.add(bd);
           jf.pack();
           jf.setVisible(true);
         }
     
    }

     
    class Butterfly extends Monster {
     
      public Butterfly(int x, int y, Sprite.Directions d) {
        super(x, y, d);
      }
     
      public void changeDirection() {
        switch(myd){
          case RIGHT:
            myd = Sprite.Directions.UP;
            break;
          case LEFT:
            myd = Sprite.Directions.DOWN;
            break;
          case UP:
            myd = Sprite.Directions.LEFT;
            break;
          case DOWN:
            myd = Sprite.Directions.RIGHT;
            break;
        }
      }
    }

     
    class Diamond extends Sprite {
      public boolean falling = false;
     
      Diamond() {
        mx = 0;
        my = 0;
      }
     
      Diamond(int x, int y) {
        mx = x;
        my = y;
      }
    }

     
    class Firefly extends Monster {
     
      public Firefly(int x, int y, Sprite.Directions d) {
        super(x, y, d);
      }
     
      public void changeDirection() {
        switch(myd){
          case LEFT:
            myd = Sprite.Directions.UP;
            break;
          case RIGHT:
            myd = Sprite.Directions.DOWN;
            break;
          case UP:
            myd = Sprite.Directions.RIGHT;
            break;
          case DOWN:
            myd = Sprite.Directions.LEFT;
            break;
        }
      }
    }

     
    import javax.xml.parsers.*;
    import javax.xml.xpath.*;
    import org.w3c.dom.*;
    import org.w3c.dom.ls.*;
    import org.xml.sax.*;
    import java.io.*;
    import java.util.*;
     
     
    public class GameUtils {
     
        private final int WIDTH = 40, HEIGHT = 22;
        public int level = 1;
        public int maxLevel, diamondsNeeded;
        public enum Contents {
            EMPTY, DIRT, WALL, ROCK, FALLINGROCK, DIAMOND, FALLINGDIAMOND, AMOEBA, FIREFLY, BUTTERFLY, EXIT, PLAYER;
        }
        private Document doc;
        public Contents[][] field = new Contents[WIDTH][HEIGHT];
     
     
        public Contents[][] loadGame() {
          level = 1;
          try{
            readDocument("levels.xml");
          }
          catch(Exception e) {}
          try{
            initLevel(level);
          }
          catch(Exception e) { System.out.println("error reading level");}
          return field;
        }
     
        public Contents[][] increaseLevel(int lvl) {
          try {initLevel(lvl + 1); } catch(Exception e) {}
          level += 1;
          return field;
        }
     
        public int[] getPlayerLocation(Contents[][] field) {
          int[] ret = new int[2];
          for(int x = 0; x < 40; x ++) {
            for(int y = 0; y < 22; y++) {
              if(field[x][y] == Contents.PLAYER) {
                ret[0] = x;
                ret[1] = y;
                return ret;
              }
            }
          }
          return ret;
        }
     
     
          /*******************************************************************************************************/
        // Call this method only once at the beginning of your program. It reads the XML level file into a DOM.
        // Do not modify this method. (method provided by professor)
        private void readDocument(String filename) throws Exception {
            File f = new File(filename);
            DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
            DocumentBuilder db = dbf.newDocumentBuilder();
            doc = db.parse(f);
            XPathFactory xpf = XPathFactory.newInstance();
            XPath path = xpf.newXPath();
            maxLevel = Integer.parseInt(path.evaluate("count(levelset/level)", doc));
        }
     
        // Call this method every time you want to start playing the given level. Do not modify this method unless
        // you really need to and are 100% sure of what you are doing. (method provided by professor)
        private void initLevel(int level) throws Exception {
            for(int x = 0; x < WIDTH; x++) {
                for(int y = 0; y < HEIGHT; y++) {
                    field[x][y] = Contents.DIRT;
                }
            }
     
            Map<String, Contents> map = new HashMap<String, Contents>();
            map.put("wall", Contents.WALL);
            map.put("rock", Contents.ROCK);
            map.put("diamond", Contents.DIAMOND);
            map.put("amoeba", Contents.AMOEBA);
            map.put("dirt", Contents.DIRT);
            map.put("empty", Contents.EMPTY);
            map.put("firefly", Contents.FIREFLY);
            map.put("butterfly", Contents.BUTTERFLY);
            map.put("exit", Contents.EXIT);
            map.put("player", Contents.PLAYER);
     
            NodeList nlist = doc.getElementsByTagName("levelset");
            Node n = nlist.item(0);
            nlist = n.getChildNodes();
            int lvl = 0;
            for(int i = 0; lvl < level && i < nlist.getLength(); i++) {
                n = nlist.item(i);
                if(n.getNodeName().equals("level")) { lvl++; }
            }            
            diamondsNeeded = Integer.parseInt(n.getAttributes().getNamedItem("diamonds").getNodeValue());
            nlist = n.getChildNodes();
            for(int i = 0; i < nlist.getLength(); i++) {
                Node e = nlist.item(i);
                String tag = e.getNodeName();
                if(!map.containsKey(tag)) continue;
                NamedNodeMap attr = e.getAttributes();
                int x = Integer.parseInt(attr.getNamedItem("x").getNodeValue());
                int y = Integer.parseInt(attr.getNamedItem("y").getNodeValue());
     
                field[x][y] = map.get(tag);
            }
        }
     
     
    }

    abstract class Monster extends Sprite
    {
      public boolean alive = true;  
      public enum Monsters {FIREFLY, BUTTERFLY} 
      public Directions myd;
     
      public Monster(int x, int y, Sprite.Directions d)
      {
        mx = x;
        my = y;
        myd = d;
      }
     
     
      public abstract void changeDirection();
     
      public Directions getDirection()
      {
        return myd;
      }
     
    }

    class Player extends Sprite 
    {
      public int diamonds;
      public boolean alive = true;
      public int points = 0;
     
      Player() {
        mx = 0;
        my = 0;
      }
     
      Player(int x, int y) {
        mx = x;
        my = y;
      }
     
      public void increasePoints(int x)
      {
        diamonds += 1;
        points += x;
      }
    }

    abstract class Sprite
    {
      public int mx;
      public int my;
      public enum Directions {LEFT, RIGHT, UP, DOWN, RANDOM}  
     
      public int getX() 
      {
        return mx;
      }
     
      public int getY()
      {
        return my;
      }
     
      public void setX(int x)
      {
        mx = x;
      }
     
      public void setY(int y)
      {
        my = y;
      }
     
      public int[] getLocation()
      {
        int[] loc = new int[2];
        loc[0] = mx;
        loc[1] = my;
        return loc;
      }
     
     
    }

  7. #7
    Super Moderator curmudgeon's Avatar
    Join Date
    Aug 2012
    Posts
    1,130
    My Mood
    Cynical
    Thanks
    64
    Thanked 139 Times in 134 Posts

    Default Re: Boulderdash

    Original poster -- I've merged your two separate threads on this same subject into one thread. Please try not to divide the discussion in multiple threads in the future.

  8. #8
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    SW Missouri
    Posts
    20,105
    Thanks
    48
    Thanked 2,153 Times in 2,126 Posts

    Default Re: Boulderdash

    Way too much code to go through. Can you make a smaller program that compiles, executes and shows the problem.
    There must be lots of code in what you posted that is not related to the problem and that can be removed.
    If you don't understand my answer, don't ignore it, ask a question.

  9. #9
    Junior Member
    Join Date
    Mar 2013
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Boulderdash

     
     
    import javax.swing.*;
    import java.awt.*;
    // This class will allow us to define features of the different types of blocks in the game
     
    public class Block {
     
    	int x = 0;	
    	int y = 0;
    	boolean visible = true;
     
    	String blockType = "";
    	// Initialize the block
    	public Block ()
    	{
    		setPos(0,0);
    		setType("");
    		visible = true;
    	}
     
    	// Set the position of the block
    	public void setPos (int stone_x, int stone_y)
    	{
    		x = stone_x;
    		y = stone_y;
     
    	}
     
    	public Boolean isVisible()
    	{
    		return visible;
    	}
     
    	public void setVisible(Boolean b)
    	{
    		visible = b;
    	}
     
    	//Get position of the block
    	public Point getPos()
    	{
    		Point blockPos = new Point();
    		blockPos.x = x;
    		blockPos.y = y;
    		return (blockPos);
    	}
     
     
    	// Set type of the block: limited to dirt, stone, gem
    	public void setType (String type)
    	{
    		blockType = type;
    	}
     
    	// Get type of the block: 
    	public char getType()
    	{
    		char type;
    		type = blockType.charAt(0);
    		return type;
    	}
     
     
     
     
     
    }

     
    import java.awt.*;
    import java.awt.event.KeyEvent;
    import java.awt.event.KeyListener;
    import java.util.*;
    import javax.swing.*;
     
     
     
    //----------------------------------------------------------------- 
    //LevelGen.java 
    //
    // This class will extract level information from Level.java, create a two dimensional array to be
    // drawn onto the screen for our level.
    //-----------------------------------------------------------------
     
    public class LevelGen extends JPanel {
     
     
    	final int MAP_ROWS = 5;
    	final int MAP_COLUMNS = 5;
    	final int IMG_WIDTH = 64;
    	final int IMG_HEIGHT = 64;
     
    	String line1 = "dbgbs";
    	String line2 ="bbsgg";
    	String line3 = "gggbg";
    	String line4 = "bbbss";
    	String line5 = "bsbgg";
     
     
    	String strMap = line1 + line2 + line3 + line4 + line5;
    	Toolkit toolkit = getToolkit();
    	int numStone =0;
    	int numBomb = 0;
    	int numGem = 0;
     
    	int dozerX = 64;
    	int dozerY = 64;
     
     
     
    	private Image imgStone = null;
    	private Image imgGem = null;
    	private Image imgBomb = null;
    	private Image imgDirt = null;
    	private ImageIcon imgDozer = new ImageIcon("dozer.png");
     
     
    	int x = 0;
    	int y = 0;
     
    	Block[][] map = new Block[MAP_ROWS][MAP_COLUMNS];
     
    	public LevelGen()
    	{
     
    		fillMap();
    		imgStone = toolkit.createImage("stone.png");
    		imgGem = toolkit.createImage("gem.png");
    		imgBomb = toolkit.createImage("bomb.png");
    		imgDirt = toolkit.createImage("dirt.png");
    		setBackground(Color.black);
    		setFocusable(true);
     
    		addKeyListener (new DirectionListener());
     
     
    	}
     
    	public void paintComponent (Graphics g)
    	{
     
    		super.paintComponent(g);
     
    		Color transparent = new Color(0, 0, 0, 0);
     
     
    		for (int i = 0; i < MAP_ROWS ; i++){
     
    			y = (i*IMG_HEIGHT);
     
    			for (int j = 0; j < MAP_ROWS ; j++)
    			{	
    				// checks if block is supposed to be visible
    				if (map[i][j].isVisible())
    				{
     
    					//char type = strMap.charAt(count);
    					char type = map[i][j].getType();
     
    					x = (j*IMG_WIDTH);
    					switch ((char)type)
    					{
    					case 'S':
    						//draw new stone image
     
    						g.drawImage(imgStone, x, y, transparent, this);
    						break;
    					case 'B':
    						// draw new bomb image
    						g.drawImage(imgBomb, x, y, transparent, this);					
    						break;
    					case 'G':
    						// draw new gem image
    						g.drawImage(imgGem, x, y, transparent, this);
    						break;
    					case 'D':
    						// draw dozer;
    						imgDozer.paintIcon(this, g, dozerX, dozerY);
    					default:break;
    					}
    				}
    				else
    				{
    					g.setColor(Color.black);
    					g.fillRect(x, y, IMG_HEIGHT, IMG_WIDTH);
    				}
     
    				printArray();
     
     
    			}
     
    			}
     
    				// retrieve value from strMap and convert it into line by line
    				// information about what tile to place in each array field
     
     
     
     
    				//map[i][j] = strMap.charAt(count);
     
     
    			}
     
     
     
     
     
    	public void fillMap ()
    	{
     
    		int count = 0;
     
    		for (int i = 0; i < MAP_ROWS ; i++){
    			y = 0;
    			y = y + (i*IMG_HEIGHT);
     
    			for (int j = 0; j < MAP_ROWS ; j++)
    			{	
    				map[i][j] = new Block();
    				char a = strMap.charAt(count);
    				x = 0;
    				x = x + (j*IMG_WIDTH);
    				map[i][j].setVisible(true);
    				switch ((char)(a))
    				{
    				case 's':
    					//fill array at i & j with stone values
    					map[i][j].setPos(x, y);
    					map[i][j].setType("Stone");
    					break;
    				case 'b':
    					// draw new bomb image
    					map[i][j].setPos(x, y);
    					map[i][j].setType("Bomb");				
    					break;
    				case 'g':
    					// draw new gem image
    					map[i][j].setPos(x, y);
    					map[i][j].setType("Gem");
    					break;
    				case 'd':
    					map[i][j].setPos(x, y);
    					map[i][j].setType("Dozer");
    					dozerX = x;
    					dozerY = y;
    				default:break;
    				}
     
    				count++;
     
    			}
    		}
     
    	}
     
    /*	public void calcElements ()
    	{
    		int count = 0;
    		char a = strMap.charAt(count);
     
    		for (int i = 0; i < strMap.length() ; i++)
    		{
    			switch ((char)(a))
    			{
     
    			case 's':
    				numStone++;
    				break;
    			case 'g':
    				numGem++;
    				break;
    			case 'b':
    				numBomb++;
    				//break;
    			default:break;
    			}
     
    		}
     
     
    	}
    	*/
    	//
    	private class DirectionListener implements KeyListener
    	{
     
     
    		public void keyPressed (KeyEvent e)
    		{
    			int i, j;
    			i =0;
    			j =0;
     
    			switch (e.getKeyCode())
    			{
    			case KeyEvent.VK_UP:
    				if(dozerY >= IMG_HEIGHT)
    				{
    					dozerY = dozerY - IMG_HEIGHT;
    					i = dozerY - IMG_HEIGHT;
    					i = i / IMG_HEIGHT;
    					j = dozerX / IMG_WIDTH;
    					map[i][j].setVisible(false);
    					repaint();
    				}
     
    				break;
     
    			case KeyEvent.VK_DOWN:
    				if (dozerY < (HEIGHT - IMG_HEIGHT))
    				{
    					dozerY = dozerY + IMG_HEIGHT;
    					i = dozerY + IMG_HEIGHT;
    					i = i / IMG_HEIGHT;
    					j = j / IMG_WIDTH;
    					map[i][j].setVisible(false);
    					repaint();
    					printArray();
    				}
    				break;
    			case KeyEvent.VK_LEFT:
    				if (dozerX >= IMG_WIDTH){dozerX= dozerX- IMG_WIDTH;}
    				break;
    			case KeyEvent.VK_RIGHT:
    				if(dozerX  < (WIDTH-IMG_WIDTH)){dozerX += IMG_WIDTH;}
    				break;	
    			}
     
     
     
     
    		}
     
    		public void keyTyped (KeyEvent e) {}
    		public void keyReleased (KeyEvent e) {}
     
    	}
     
    	public void printArray ()
    	{
    		for (int i = 0; i < MAP_ROWS ; i++)
    		{
    			for (int j = 0; j < MAP_COLUMNS ; j++)
    			{
    				System.out.print("" + map[i][j].getType());
    				System.out.println("" + map[i][j].getPos());
    			}
     
    			System.out.println("");
     
    		}
    	}
     
    }

     
     
     
     
     
    import javax.swing.*;
    import java.awt.*;
     
    public class GameFrame {
     
    	public static void main (String[] args)
    	{
     
    		JFrame frame = new JFrame ("Boulder Dash");
    		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    		frame.setSize(new Dimension(500,500));
    		frame.getContentPane().add(new LevelGen());
    		frame.setVisible(true);
     
     
     
    	}
     
     
    }

  10. #10
    Junior Member
    Join Date
    Mar 2013
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Boulderdash

     
     
    import javax.swing.*;
    import java.awt.*;
    // This class will allow us to define features of the different types of blocks in the game
     
    public class Block {
     
    	int x = 0;	
    	int y = 0;
    	boolean visible = true;
     
    	String blockType = "";
    	// Initialize the block
    	public Block ()
    	{
    		setPos(0,0);
    		setType("");
    		visible = true;
    	}
     
    	// Set the position of the block
    	public void setPos (int stone_x, int stone_y)
    	{
    		x = stone_x;
    		y = stone_y;
     
    	}
     
    	public Boolean isVisible()
    	{
    		return visible;
    	}
     
    	public void setVisible(Boolean b)
    	{
    		visible = b;
    	}
     
    	//Get position of the block
    	public Point getPos()
    	{
    		Point blockPos = new Point();
    		blockPos.x = x;
    		blockPos.y = y;
    		return (blockPos);
    	}
     
     
    	// Set type of the block: limited to dirt, stone, gem
    	public void setType (String type)
    	{
    		blockType = type;
    	}
     
    	// Get type of the block: 
    	public char getType()
    	{
    		char type;
    		type = blockType.charAt(0);
    		return type;
    	}
     
     
     
     
     
    }

     
    import java.awt.*;
    import java.awt.event.KeyEvent;
    import java.awt.event.KeyListener;
    import java.util.*;
    import javax.swing.*;
     
     
     
    //----------------------------------------------------------------- 
    //LevelGen.java 
    //
    // This class will extract level information from Level.java, create a two dimensional array to be
    // drawn onto the screen for our level.
    //-----------------------------------------------------------------
     
    public class LevelGen extends JPanel {
     
     
    	final int MAP_ROWS = 5;
    	final int MAP_COLUMNS = 5;
    	final int IMG_WIDTH = 64;
    	final int IMG_HEIGHT = 64;
     
    	String line1 = "dbgbs";
    	String line2 ="bbsgg";
    	String line3 = "gggbg";
    	String line4 = "bbbss";
    	String line5 = "bsbgg";
     
     
    	String strMap = line1 + line2 + line3 + line4 + line5;
    	Toolkit toolkit = getToolkit();
    	int numStone =0;
    	int numBomb = 0;
    	int numGem = 0;
     
    	int dozerX = 64;
    	int dozerY = 64;
     
     
     
    	private Image imgStone = null;
    	private Image imgGem = null;
    	private Image imgBomb = null;
    	private Image imgDirt = null;
    	private ImageIcon imgDozer = new ImageIcon("dozer.png");
     
     
    	int x = 0;
    	int y = 0;
     
    	Block[][] map = new Block[MAP_ROWS][MAP_COLUMNS];
     
    	public LevelGen()
    	{
     
    		fillMap();
    		imgStone = toolkit.createImage("stone.png");
    		imgGem = toolkit.createImage("gem.png");
    		imgBomb = toolkit.createImage("bomb.png");
    		imgDirt = toolkit.createImage("dirt.png");
    		setBackground(Color.black);
    		setFocusable(true);
     
    		addKeyListener (new DirectionListener());
     
     
    	}
     
    	public void paintComponent (Graphics g)
    	{
     
    		super.paintComponent(g);
     
    		Color transparent = new Color(0, 0, 0, 0);
     
     
    		for (int i = 0; i < MAP_ROWS ; i++){
     
    			y = (i*IMG_HEIGHT);
     
    			for (int j = 0; j < MAP_ROWS ; j++)
    			{	
    				// checks if block is supposed to be visible
    				if (map[i][j].isVisible())
    				{
     
    					//char type = strMap.charAt(count);
    					char type = map[i][j].getType();
     
    					x = (j*IMG_WIDTH);
    					switch ((char)type)
    					{
    					case 'S':
    						//draw new stone image
     
    						g.drawImage(imgStone, x, y, transparent, this);
    						break;
    					case 'B':
    						// draw new bomb image
    						g.drawImage(imgBomb, x, y, transparent, this);					
    						break;
    					case 'G':
    						// draw new gem image
    						g.drawImage(imgGem, x, y, transparent, this);
    						break;
    					case 'D':
    						// draw dozer;
    						imgDozer.paintIcon(this, g, dozerX, dozerY);
    					default:break;
    					}
    				}
    				else
    				{
    					g.setColor(Color.black);
    					g.fillRect(x, y, IMG_HEIGHT, IMG_WIDTH);
    				}
     
    				printArray();
     
     
    			}
     
    			}
     
    				// retrieve value from strMap and convert it into line by line
    				// information about what tile to place in each array field
     
     
     
     
    				//map[i][j] = strMap.charAt(count);
     
     
    			}
     
     
     
     
     
    	public void fillMap ()
    	{
     
    		int count = 0;
     
    		for (int i = 0; i < MAP_ROWS ; i++){
    			y = 0;
    			y = y + (i*IMG_HEIGHT);
     
    			for (int j = 0; j < MAP_ROWS ; j++)
    			{	
    				map[i][j] = new Block();
    				char a = strMap.charAt(count);
    				x = 0;
    				x = x + (j*IMG_WIDTH);
    				map[i][j].setVisible(true);
    				switch ((char)(a))
    				{
    				case 's':
    					//fill array at i & j with stone values
    					map[i][j].setPos(x, y);
    					map[i][j].setType("Stone");
    					break;
    				case 'b':
    					// draw new bomb image
    					map[i][j].setPos(x, y);
    					map[i][j].setType("Bomb");				
    					break;
    				case 'g':
    					// draw new gem image
    					map[i][j].setPos(x, y);
    					map[i][j].setType("Gem");
    					break;
    				case 'd':
    					map[i][j].setPos(x, y);
    					map[i][j].setType("Dozer");
    					dozerX = x;
    					dozerY = y;
    				default:break;
    				}
     
    				count++;
     
    			}
    		}
     
    	}
     
    /*	public void calcElements ()
    	{
    		int count = 0;
    		char a = strMap.charAt(count);
     
    		for (int i = 0; i < strMap.length() ; i++)
    		{
    			switch ((char)(a))
    			{
     
    			case 's':
    				numStone++;
    				break;
    			case 'g':
    				numGem++;
    				break;
    			case 'b':
    				numBomb++;
    				//break;
    			default:break;
    			}
     
    		}
     
     
    	}
    	*/
    	//
    	private class DirectionListener implements KeyListener
    	{
     
     
    		public void keyPressed (KeyEvent e)
    		{
    			int i, j;
    			i =0;
    			j =0;
     
    			switch (e.getKeyCode())
    			{
    			case KeyEvent.VK_UP:
    				if(dozerY >= IMG_HEIGHT)
    				{
    					dozerY = dozerY - IMG_HEIGHT;
    					i = dozerY - IMG_HEIGHT;
    					i = i / IMG_HEIGHT;
    					j = dozerX / IMG_WIDTH;
    					map[i][j].setVisible(false);
    					repaint();
    				}
     
    				break;
     
    			case KeyEvent.VK_DOWN:
    				if (dozerY < (HEIGHT - IMG_HEIGHT))
    				{
    					dozerY = dozerY + IMG_HEIGHT;
    					i = dozerY + IMG_HEIGHT;
    					i = i / IMG_HEIGHT;
    					j = j / IMG_WIDTH;
    					map[i][j].setVisible(false);
    					repaint();
    					printArray();
    				}
    				break;
    			case KeyEvent.VK_LEFT:
    				if (dozerX >= IMG_WIDTH){dozerX= dozerX- IMG_WIDTH;}
    				break;
    			case KeyEvent.VK_RIGHT:
    				if(dozerX  < (WIDTH-IMG_WIDTH)){dozerX += IMG_WIDTH;}
    				break;	
    			}
     
     
     
     
    		}
     
    		public void keyTyped (KeyEvent e) {}
    		public void keyReleased (KeyEvent e) {}
     
    	}
     
    	public void printArray ()
    	{
    		for (int i = 0; i < MAP_ROWS ; i++)
    		{
    			for (int j = 0; j < MAP_COLUMNS ; j++)
    			{
    				System.out.print("" + map[i][j].getType());
    				System.out.println("" + map[i][j].getPos());
    			}
     
    			System.out.println("");
     
    		}
    	}
     
    }

     
     
     
     
     
    import javax.swing.*;
    import java.awt.*;
     
    public class GameFrame {
     
    	public static void main (String[] args)
    	{
     
    		JFrame frame = new JFrame ("Boulder Dash");
    		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    		frame.setSize(new Dimension(500,500));
    		frame.getContentPane().add(new LevelGen());
    		frame.setVisible(true);
     
     
     
    	}
     
     
    }

  11. #11
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    SW Missouri
    Posts
    20,105
    Thanks
    48
    Thanked 2,153 Times in 2,126 Posts

    Default Re: Boulderdash

    Do you have any comments or questions about the code posted in the last posts (#9 & 10)?
    If you don't understand my answer, don't ignore it, ask a question.

  12. #12
    Junior Member
    Join Date
    Mar 2013
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Boulderdash

    Yes. it shows a blank screen only. what do I need to add to make this boulderdash game work?

  13. #13
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    SW Missouri
    Posts
    20,105
    Thanks
    48
    Thanked 2,153 Times in 2,126 Posts

    Default Re: Boulderdash

    Try debugging the code by adding println statements that print out messages to show that the images have loaded ok and that the drawImage() methods is being called.

    What should the code posted in posts # 9 & 10 show on the screen?
    If you don't understand my answer, don't ignore it, ask a question.

  14. #14
    Junior Member
    Join Date
    Mar 2013
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Boulderdash

    The objects need to be seen/created. the player, diamonds, rocks etc that boulderdash is supposed to have. I actulay didn't create this I just need any working source code I could have for boulderdash. I cant find it anywhere when I search on google

  15. #15
    Super Moderator curmudgeon's Avatar
    Join Date
    Aug 2012
    Posts
    1,130
    My Mood
    Cynical
    Thanks
    64
    Thanked 139 Times in 134 Posts

    Default Re: Boulderdash

    Quote Originally Posted by D4rk_H34rt View Post
    The objects need to be seen/created. the player, diamonds, rocks etc that boulderdash is supposed to have. I actulay didn't create this I just need any working source code I could have for boulderdash. I cant find it anywhere when I search on google
    You need to learn how to code in Java first so that you in fact can create this and have it work.

  16. #16
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    SW Missouri
    Posts
    20,105
    Thanks
    48
    Thanked 2,153 Times in 2,126 Posts

    Default Re: Boulderdash

    Make sure the image files are being read. I don't know if the classes and methods you are using give any errors if the images are not read. Try using the ImageIO class's to read the images. They give error messages if the images are not found.

    An easy way to see what the classes and methods you are using will do with a non-existent image file is to use the name of a file that does not exist and see if there is an error.
    If you don't understand my answer, don't ignore it, ask a question.