Turning to the Greenfoot community for help, once more -w-'
So I need a code that if a button is pressed it would negate an if statement?
here's my code and what I intend to happen is that if leftCount == 1 it would negate rightCount == 1 and vice versa but i'm not sure how to code it so that if rightCount or leftCode == 2 it won't be affected by the negated command.
I'm making a choice based game and decided to use the left and right button for the player to 'choose' between 2 choices.
private boolean leftDown;
private boolean rightDown;
private int leftCount;
private int rightCount;
public void Choices()
{
if (!leftDown && Greenfoot.isKeyDown("left"))
{
leftDown= true;
leftCount++;
if (leftCount == 1) addObject(new Utxt(),96,45);
else if (leftCount == 2) addObject(new Utxt2(),96, 168);
if (leftCount == 1) addObject(new Unkown(),48,30);
else if (leftCount == 2) addObject(new Unkown(),48, 155);
}
if (!rightDown && Greenfoot.isKeyDown("right"))
{
rightDown= true;
rightCount++;
if (rightCount == 1) addObject(new Utxt(),96,45);
else if (rightCount == 2) addObject(new Utxt2(),96, 168);
if (rightCount == 1) addObject(new Unkown(),48,30);
else if (rightCount == 2) addObject(new Unkown(),48, 155);
}
if (leftDown && !Greenfoot.isKeyDown("left"))
{
leftDown= false;
}
if (rightDown && !Greenfoot.isKeyDown("right"))
{
rightDown= false;
}
}
