I want to control the direction of the bullet, when i press space and right it have to fly right when i press space and left it have to fly left and so on
i came up with this idea :
but it says that operator && can not be applied to boolean,java.lang.string
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | if (Greenfoot.isKeyDown ( "space" ) && ( "right" )) { setLocation(getX() + 36 , getY()); } if (Greenfoot.isKeyDown ( "space" ) && ( "left" )) { setLocation(getX() - 36 , getY()); } if (Greenfoot.isKeyDown ( "space" ) && ( "up" )) { setLocation(getX()+ 0 , getY ()+ 36 ); } if (Greenfoot.isKeyDown ( "space" ) && ( "down" )) { setLocation(getX() + 0 , getY()- 36 ); } |