I have encountered a problem while writing code for a small game I've been working on. In the following code I am trying to use object oriented programming. as I am using KeyEvent I think I need to use 2 methods however for some reason int key cannot be found. Can somebody help me?
class KeyEvt {
void keyPressed (KeyEvent e)
{
int key = e.getKeyCode();
}
}
class Dodger {
public static void main (String args[])
{
boolean GameOver = false;
int obst;
KeyEvt left = new KeyEvt();
do
{
obst = (int) (Math.random() * 4) +1;
if (obst == 1)
{
System.out.println(" ---");
if (KeyEvt.key == KeyEvent.VK_LEFT){}
}