I have a program where a knight and lance switch between three lanes, it uses a get key to move either up or down, however only one of the two ever moves at a time.
String key = Greenfoot.getKey(); System.out.println(key); if("w".equals(key) ){ System.out.println("here"); if(y > 100){ y = y - 100; charge(y,di); } } if("s".equals(key)){ System.out.println("here"); if(y < 300){ y = y + 100; charge(y,di); } } if(Greenfoot.isKeyDown("space")){ System.out.println("pere"); } else{ charge(y,di); }