Hopefully this clarifies things, thanks in advance.
Please correct me if I'm wrong, but I presume this is how it is used, or would I have to make an object of sorts? Thanks for the replies.
Beware: The System.in.read() method declares it throws an IOException, which is checked, so you must deal with that exception somehow.
KeyListeners might work, but I think that would require a GUI component which has the focus. I have never found a way of implementing the "press any key to continue" in Java.
Has anybody else got any ideas, please?
As this is a learning site and not a "do your homework for you" site I'll only be posting code fragments and psudo-code. It should be enough though for you to figure the rest out from (sorry). When is your assignment due by? Have you gotten the rest of the program done? Is anything else holding you up? Are you adding mouse functionality to it (not much more code then keyboard reading)?
I don't know what your level of experience or how involved the pacman game is but keep in mind that if you're programming correctly using object oriented methods then even if you are completely hammered on the key-reading part you should still be able to write everything else. Hope that made sense. I should be able to get something posted for you in 2-3 hours.
This method is called when a key was pressed. Override it if your world wants to consume some keys (e.g. "1"-"9" for Sudoku). Don't consume plain arrow keys, or the user loses the ability to move the selection square with the keyboard.
description - the string describing the key, in this format.
loc - the selected location in the grid at the time the key was pressed
true if the world consumes the key press, false if the GUI should consume it.
Perhaps, this is the method you should be looking to implement.
Thanks everybody fr the help. It's much appreciated.
Please don't. We all want to see the solution. Look at this FAQ.
Brian Legg wrote:PM sent