Changes to the Console class ---------------------------- The Console class provided by Packman's current version of Ready does not work with all versions of Java. As a consequence, some of you will get program crashes when redrawing the screen. That's the fault of the incompatibility between the version of Ready and the version of Java. To get around this problem, I'm providing a Console class that does not rely upon Ready. Additionally, this class will provide interactive keystroke input, so you don't have to press Enter after every keystroke. Changes to make --------------- Here's what to do to incorporate the new Console into your code: 1. Copy the Console.java file from http://www.cs.queensu.ca/~jstewart/124/Console.java into the directory of your program. 2. At the very, very end of the draw() method of your Board class, add this line: console.repaint(); That should be all that you need to do. The Console methods, setCursor(), print(), and readChar(), have been replaced in the new Console class, and behave as they did in the original class (except that readChar() now doesn't require Enter to be pressed). Note that if you used other methods from the old Console class, they are not available in the new Console class! But you should be able to modify your code to use only the three methods above. Interactive keystrokes ---------------------- To get interactive keystrokes, use the new Console's readChar() method. This method does not wait until the Enter key is pressed. It returns with the key as soon as the key is pressed. (Note that you might have to place your mouse inside the console window for keystrokes to be recognized. In some systems, you might even have to click in that window before keystrokes will be recognized.) Sample program -------------- The above changes have been made to the a1.zip file available at http://www.cs.queensu.ca/~jstewart/124/a1.zip Furthermore, the Game and Player classes have been modified to show the interactive keystroke feature in action. The Game class was modified so that the main() code looks like public static void main( String [] s ) { String boardName = "board1.txt"; if (s.length > 0) boardName = s[0]; Game game = new Game( boardName); while (game.board.person.isAlive()) { Position newPos = game.board.person.proposeMove(); game.board.person.setPosition( newPos ); game.board.draw(); } } The Person class has been modified so that the proposeMove() method looks like public Position proposeMove() { Position newPos = new Position( pos.x, pos.y ); char c = console.readChar(); switch (c) { case 'h': newPos.x--; break; case 'j': newPos.y++; break; case 'k': newPos.y--; break; case 'l': newPos.x++; break; } return newPos; } If you would like try out the interactive keystokes, make the above two changes to your own code, and run it. Or, better yet, keep your own code untouched and download the new a1.zip file into a *new* directory and run that without making *any* changes to the code. That's a better idea, because the new a1.zip code should compile and run without errors, whereas errors might be introduced if you make the above modifications to your own code.