froggerhelp
08-01-2006, 05:19 PM
we're making the game frogger, and we're having trouble getting keylistener to work. this is our code so far for our main program:
public class Frogger extends GraphicsProgram implements KeyListener
{
// instance variables
private Room myRoom;
public void init()
{
System.out.println("constructed frogger");
myRoom = new Room (400, 350, getGCanvas ());
this.setFocusable(true);
this.addKeyListener(this);
}
public void keyPressed(KeyEvent e){System.out.println(e.getKeyCode());}
public void keyReleased(KeyEvent e){System.out.println(e.getKeyCode());}
public void keyTyped(KeyEvent e)
{
System.out.println(e.getKeyCode());
}
public class Frogger extends GraphicsProgram implements KeyListener
{
// instance variables
private Room myRoom;
public void init()
{
System.out.println("constructed frogger");
myRoom = new Room (400, 350, getGCanvas ());
this.setFocusable(true);
this.addKeyListener(this);
}
public void keyPressed(KeyEvent e){System.out.println(e.getKeyCode());}
public void keyReleased(KeyEvent e){System.out.println(e.getKeyCode());}
public void keyTyped(KeyEvent e)
{
System.out.println(e.getKeyCode());
}