hello, I got this maze source code from the internet but I would like to change it so that the movement uses keypad (UP,DOWN,LEFT,RIGHT) instead of mouselistener
Any help would be great (it is an Applet) :D
here is the Source Code attached:
Printable View
hello, I got this maze source code from the internet but I would like to change it so that the movement uses keypad (UP,DOWN,LEFT,RIGHT) instead of mouselistener
Any help would be great (it is an Applet) :D
here is the Source Code attached:
So you're looking to create a KeyListener, which will listen to the keys you've indicated. Take a look at the API docs for the KeyListener interface.
tried I changed all the mouse functions to use keylistener instead but I get these errors:
H:\Java\maze\MazeApplet.java:365: cannot resolve symbol
symbol : method getPoint ()
location: class java.awt.event.KeyEvent
Point p = new Point(e.getPoint());
^
H:\Java\maze\MazeApplet.java:366: cannot resolve symbol
symbol : method getX ()
location: class java.awt.event.KeyEvent
int x = e.getX();
^
H:\Java\maze\MazeApplet.java:367: cannot resolve symbol
symbol : method getY ()
location: class java.awt.event.KeyEvent
int y = e.getY();
^
3 errors
there is no getPoint() in KeyEvent class. there is no location for a key event at all. getX, getY are functions for a mouseevent, which has a location on the screen, and not for a keyevent, which has no location but the keyboard itself. remove all code corresponding to the location of the mouse.Quote:
H:\Java\maze\MazeApplet.java:365: cannot resolve symbol
symbol : method getPoint ()
location: class java.awt.event.KeyEvent
Point p = new Point(e.getPoint());