Missing left curly bracket

class Player {
  float playerY = 0;
  float playerX;
  char keyUp;
  char keyDown;
  Player(char keyU, char keyD, float pX) {
    keyUp = keyU;
    keyDown = keyD;
    playerX = pX;
  }
  void drawPlayer () {
    fill(255);
    rect(playerX, playerY, 25, 100);
  }
  if (keyPressed) {
    if (!game_over) {
      if (key == keyDown) {
        if (playerY + 100 < 500) {
          playerY += 7;
        }
      } else if (key == keyUp) {
        if (playerY > 0 ) {
          playerY -= 7;
        }
      }
    }
  }
}

Hi! Inside a class you can only declare variables and functions. You can’t have an if statement directly inside a class. The if statement must be located inside a function definition.

1 Like

Ok, thank you for your answer.

Hi Blue_Obsidian,

Can you edit your title for something smaller and put the description of your problem in your first post please?

Ok, i’ll do it next time.

1 Like