Simple Game Help

I'm using a CyberCortex AV that has LEDs from 32 to 35 and buttons from 40 to 43. I want to make a simple game - press the button while the other player is pressing - if you do, you win. However, what I actually get is that LEDs 1 to 3 are on, and pressing left button causes led 1 to go off. I'm not sure why, and I've re-written the code, but it still has the same behaviour.

int firstWas = -1;
void setup() {
  pinMode(32, OUTPUT);
  pinMode(35, OUTPUT);
  pinMode(40, INPUT);
  pinMode(43, INPUT);
  resetLights();
}
void loop() {
  checkForInputs();
}
void checkForInputs(){
  boolean leftDown = false;
  boolean rightDown = false;
  if(digitalRead(40)){
    leftDown = true;
    if(firstWas == -1){
      firstWas = 0;
    }
  }
  if(digitalRead(43)){
    rightDown = true;
    if(firstWas == -1){
      firstWas = 1;
    }
  }
  if(leftDown && rightDown){
    if(firstWas == 0){
      gameOver(1);
    } else {
      gameOver(0);
    }
    firstWas = -1;
  }
}
void gameOver(int who){
  if(who == 0){
    digitalWrite(35, HIGH);
    delay(600);
  } else {
    digitalWrite(32, HIGH);
    delay(600);
  }
  resetLights();
}
void resetLights(){
  digitalWrite(32, LOW);
  digitalWrite(35, LOW);
}

Thanks

I want to make a simple game - press the button while the other player is pressing - if you do, you win.

Your code doesn't do what you say.

What it is doing is

I want to make a simple game - press the button before the other player presses- if you do, you win.

your code I extracted below doesn't handle if only one button is pressed. Which will occur frequently as Mhz is faster than humans reaction speed

//Time from start of function to here is very short
if(leftDown && rightDown){
    if(firstWas == 0){
      gameOver(1);
    } else {
      gameOver(0);
    }
    firstWas = -1;
  }

EDIT: your code should do what you want if you put the

  boolean leftDown = false;
  boolean rightDown = false;

in global scope like

int firstWas = -1;

in function scope those values are lost when the function returns and the code behaves like I described. So it either has to evaluate the result in one go or you have to give it access to the information later.

making the variable static in function scope will work also.