I am making a simple game where you move the actor up and down with w and s and it shoots projectiles. I got it to move up and down and shoot and stuff but how do I make it so that it only shoots 1 projectile per space press?
// add field
private boolean spaceDown; // to track state of "space" key
// in act
if (spaceDown != Greenfoot.isKeyDown("space")) // key state change
{
spaceDown = ! spaceDown; //updating state
if (spaceDown) shoot(); // shoot on key press
}// add field
private boolean spaceDown; // to track state of "space" key
// in act
if (spaceDown != Greenfoot.isKeyDown("space")) // key state change
{
spaceDown = ! spaceDown; //updating state
if (spaceDown) shoot(); // shoot on key press
}// add field
private boolean spaceDown; // to track state of "space" key
// in act
if (spaceDown != Greenfoot.isKeyDown("space")) // key state change
{
spaceDown = ! spaceDown; //updating state
if (spaceDown) shoot(); // shoot on key press
}