Hey, I'm trying to create a simple program were I can move around with the WASD keys and shoot balls from me, to whatever direction I'm facing, with "Space". I've got those two parts down but what I realize is that when I shoot the Balls, it keeps shooting them until I let go of space (in a long line). However, I want it to shoot in pulses if I hold the space bar down. To do this I thought I should use the "getObjectInRange()" method (were in an if statement it asks if a ball is within my Characters range, then if it is, dont shoot. While if a ball is not in my Characters range AND the "Space" is down, shoot).
Here is my code for the shoot :
if(Greenfoot.isKeyDown("space") )
{
getWorld().addObject(new Ball(getRotation()), getX(), getY());
}
(I've tried adding the "getObjectInRange()" but it doesnt work)
The code in the middle works fine for the thing im trying to do.
If you need any more info just ask.
Any help at all will be appreciated, but please take into consideration that Im new to programming and I need stuff to be dumbed-down.
Thanks :)