This site requires JavaScript, please enable it in your browser!
Greenfoot back

danpost's Comments

Back to danpost's profile

I once had the computer move its Queen through one of my pawns to get to my Queen. It only happened the one time and I have not been able to re-produce it since.
Changing thing up, eh? Before, it appeared all levels would be using the same world instance; now, it appears you are using different worlds (there were no 'setWorld' methods used in your first post). This changes things drastically. Your 'newLevel' method will need to determine what world is currently active to know which world to proceed to. This is done by using the 'instanceof' operator on the world object. For example: if (getworld() instanceof Asia) Greenfoot.setWorld(new Europe()); You will need a similar line for each possible level change.
If you are only going to have two levels, you can just put the code in the 'newLevel' method using the 'world.setBackground(String imageFilename)' and 'setImage(String imageFilename)' methods to make the changes. If you are adding additional levels, best would be to put the filenames in arrays and add an instance int field to track the level number and determine what index in the arrays to get the names from (still, the code for incrementing the level number and setting the images would go in the 'newLevel' method).
As far as the keys, I explained incorrectly. The problem with the feel is that you cannot jump when the 'left' or 'right' key is down. Removing the 'else' before checking if 'isKeyDown("up") should help the feel.
You need to pass the piece that creates the Dummy objects to the dummies, so it can move the proper piece to its location if it is clicked on. Add an instance field ('Piece piece') in the Dummy class and change the constructor to: public Dummy(Piece p) { piece = p; } Then you can use 'piece.setLocation(geX(), getY())' to move the piece.
The feel of the keys is wrong. You want the jump to occur when the key is pressed, not released, for a better feel.
Point two in your 'How to play' should be: 'You cannot jump OVER an empty square.'
The problem is that the MouseInfo object can be 'null' when returned by using 'getMouseInfo', You need one more additional check in the final 'if' condition and it needs to be placed first: [code]if (mouse != null && /** what you already had */)[/code]
You should always test your upload on the site to make sure it is doing what it should there. As soon as you click 'Run', the 'Pause' button flashes and the scenario stops and the 'Run' button reappears. There is an error being thrown that is preventing the scenario from running.