Error in almost all functions

Hello everyone, for me c++ is a new language. Last time i write c# scripts(unity) but im not so good there too. I have too many errors in this script, but i dont know what to do with a function errors like: (any function or function(); in code) was not declared in this scope
I read solutions but i didnt saw anything bad in code. Can you help me please?
Here is a code:

#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <Wire.h>
// pin 7 - Serial clock out (SCLK)
// pin 6 - Serial data out (DIN)
// pin 5 - Data/Command select (D/C)
// pin 4 - LCD chip select (CS)
// pin 3 - LCD reset (RST)
Adafruit_SSD1306 display = Adafruit_SSD1306(3, 4, 5, 7, 6);
#define NUMFLAKES 8
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64
#define XPOS 0
#define YPOS 1
#define DELTAY 2
#define pinX A1  // ось X джойстика
#define pinY A2 // ось Y джойстика
#define joybutton A3 // кнопка джойстика
//переменные
int OnHello = 0;
int joy = 0;
unsigned long sleepMiliSEC = 0;
int sleepSEC = 0;
int inMenu = 0;
int menuCursor = 0;
int ChosedButton = 1;
boolean FPStruefalse = 0;
boolean passwordset = 0;
boolean login = 0;
int SettingsChosedButton = 1;
int SettingsmenuCursor = 3;
boolean sleeping = 0;
void setup() {
Serial.begin(9600);
display.begin();
sleepMiliSEC = millis();
pinMode(1, INPUT);
pinMode(pinX, INPUT);
pinMode(pinY, INPUT);
pinMode(joybutton, INPUT);
digitalWrite(joybutton, HIGH);
display.setTextSize(1);
display.setTextColor(WHITE);
display.setCursor(5,5);
display.println("Hello, Sasha!");
PassCheck();
}

void loop() 
{
  JoyStickControl();
   fps(1);
  //screen sleep:
  if(UsingButton == 0)
  {
     if (millis() - sleepMiliSEC > 1000) 
     {
      sleepMiliSEC = millis();
      sleepSEC = sleepSEC + 1;
      if(sleepSEC >= 5)
      inMenu = 0;
      display.clearDisplay();
      sleeping = 1;
      }
  }
  if(UsingButton == 1)
  {
  if(sleepSEC >= 1)
  {
    sleepSEC = 0;
    sleepMiliSEC = 0;
  }
  }
      if(UsingButton == 1)
      {
        if(sleeping == 1)
        {
      GoodMorning();
        }
    }
   if(inMenu == 1)
   {
     if(pinY >= 300)
     {
       ChosedButton++;
     if(ChosedButton == 0)
     {
       ChosedButton = 3;
       display.write(" ");
       display.setCursor(10, 2);
       display.write(">");
       delay(250);
     }
     if(ChosedButton == 4)
     {
       ChosedButton = 1;
       display.write(" ");
       display.setCursor(2, 2);
       display.write(">");
       delay(250);
     }
     if(ChosedButton < 4) {
       if(ChosedButton > 0)
       {
       display.write(" ");
       display.setCursor(menuCursor + 4, 2);
       display.write(">");
       delay(250);
     }
     }
}
     if(pinY >= -300)
     {
       ChosedButton--;
       if(ChosedButton == 0)
            {
       ChosedButton = 3;
       display.write(" ");
       display.setCursor(10, 2);
       display.write(">");
       delay(250);
     }
     if(ChosedButton == 4)
     {
       ChosedButton = 1;
       display.write(" ");
       display.setCursor(2, 2);
       display.write(">");
       delay(250);
     }
     if(ChosedButton < 4) {
       if(ChosedButton > 0)
       {
       display.write(" ");
       display.setCursor(menuCursor - 4, 2);
       display.write(">");
       delay(250);
     }
     }
   }
     if(UsingButton == 1)
     {
       if(ChosedButton == 1)
       {
         FlappyBird();
         inMenu = 2;
       }
       if(ChosedButton == 2)
       {
         inMenu = 3;
       }
       if(ChosedButton == 3)
       {
         inMenu = 4;
         SettingsMenu();
       }
     }
}
void GoodMorning()
{
  display.setTextColor(WHITE);
  display.setCursor(5,5);
  display.println("Good Morning!");
  delay(500);
  display.setCursor(5,7);
  display.println("Drag a button to open menu!");
  SetPassCheck();
}
if(UsingButton == 1)
{
display.clearDisplay();
display.setTextSize(1);
display.setCursor(2,5);
display.println("flappy bird");
display.setCursor(6,5);
display.println("Заметки");
display.setCursor(10,5);
display.println("Настройки");
inMenu = 1;
delay(200);
}

void SettingsMenu()
{
  if(inMenu == 4)
     {
       display.clearDisplay();
       display.setCursor(3,2);
       display.writeln("FPS:"FPStruefalse);
       display.setCursor(1,2);
       display.write(">");
      if(pinY >= -300)
     {
       SettingsChosedButton--;
       display.write(" ");
       display.setCursor(1, SettingsmenuCursor - 2);
       if(SettingsmenuCursor == 0)
       {
         
         display.write(" ");
         display.setCursor(1, 6);
         SettingsmenuCursor = 3;
         display.write(">");
       }
     }
   }
}
void flappyBird(void) {

  uint32_t tp = millis();

  float o_speed = 0.05;

  float bird_y = 0.5;
  float bird_vy = 0;
  float g = -1;

  uint8_t birdSize = 3;

  obstacle obs1;
  obstacle obs2;

  obs2.x += SCREEN_WIDTH/2;

  int score = 0;

  bool won = false;
  
  while(true) {

    float dx = joyStick.x();
    float dy = joyStick.y();

    if(won) {
      dx = 0;
      dy = 0;
    }
    
    if (dx*dx + dy*dy > 0.5)
    {
      //jump
      bird_vy = 0.5;
    }
    
    float diff = (millis() - tp);
    tp = millis();

    bird_vy += diff * g / 500;
    bird_y += diff * bird_vy / 500;

    if(bird_y > 1) {
      bird_y = 1;
      bird_vy = 0;
    }
    if(bird_y < 0) {
      bird_y = 0;
      bird_vy = 0;
    }

    if(!won) {
      obs1.x -= diff * o_speed;
      obs2.x -= diff * o_speed;
    }

    if(obs1.x < -obs1.w/2) {
      obs1.x = SCREEN_WIDTH + obs1.w/2;
      obs1.h = (SCREEN_HEIGHT - obs1.slotSize)*(float)rand()/RAND_MAX;
      score++;
    }

    if(obs2.x < -obs2.w/2) {
      obs2.x = SCREEN_WIDTH + obs2.w/2;
      obs2.h = (SCREEN_HEIGHT - obs2.slotSize)*(float)rand()/RAND_MAX;
      score++;
    }

    if((obs1.x > 30  - LOGO_WIDTH / 2) && (obs1.x < 30  + LOGO_WIDTH / 2)) {
      bool collision = (bird_y*SCREEN_HEIGHT - LOGO_HEIGHT / 2 < SCREEN_HEIGHT-obs1.h-obs1.slotSize) || (bird_y*SCREEN_HEIGHT + LOGO_HEIGHT / 2 > SCREEN_HEIGHT-obs1.h);
      if(collision)
        won = true;
    }

    if((obs2.x > 30  - LOGO_WIDTH / 2) && (obs2.x < 30  + LOGO_WIDTH / 2)) {
      bool collision = (bird_y*SCREEN_HEIGHT - LOGO_HEIGHT / 2 < SCREEN_HEIGHT-obs2.h-obs2.slotSize) || (bird_y*SCREEN_HEIGHT + LOGO_HEIGHT / 2 > SCREEN_HEIGHT-obs2.h);
      if(collision)
        won = true;
    }

    display.clearDisplay();
    
    //display.drawCircle(30, SCREEN_HEIGHT*(1 - bird_y), birdSize, SSD1306_WHITE);

    display.drawBitmap(30  - LOGO_WIDTH / 2, SCREEN_HEIGHT*(1 - bird_y) - LOGO_HEIGHT / 2, birdpic_bmp, LOGO_WIDTH, LOGO_HEIGHT, 1);

    display.fillRect(obs1.x - obs1.w/2 + 2, 0, obs1.w - 4, obs1.h, SSD1306_WHITE);
    display.fillRect(obs1.x - obs1.w/2 + 2, obs1.h + obs1.slotSize, obs1.w - 4, SCREEN_HEIGHT - obs1.h - obs1.slotSize, SSD1306_WHITE);
    display.fillRect(obs1.x - obs1.w/2, obs1.h - 4, obs1.w, 4, SSD1306_WHITE);
    display.fillRect(obs1.x - obs1.w/2, obs1.h + obs1.slotSize, obs1.w, 4, SSD1306_WHITE);

    display.fillRect(obs2.x - obs2.w/2 + 2, 0, obs2.w - 4, obs2.h, SSD1306_WHITE);
    display.fillRect(obs2.x - obs2.w/2 + 2, obs2.h + obs2.slotSize, obs2.w - 4, SCREEN_HEIGHT - obs2.h - obs1.slotSize, SSD1306_WHITE);
    display.fillRect(obs2.x - obs2.w/2, obs2.h - 4, obs2.w, 4, SSD1306_WHITE);
    display.fillRect(obs2.x - obs2.w/2, obs2.h + obs2.slotSize, obs2.w, 4, SSD1306_WHITE);
    
    //drawObstacle(obs1);
    //drawObstacle(obs2);
    
    display.setTextSize(1);
    display.setTextColor(SSD1306_WHITE);       
    display.setCursor(4, 4);
    display.print("score: ");
    display.print(score);
    display.display();
    
    if(UsingButton == 1())
      break;
  }
void JoyStickControl()
{
  boolean UsingButton = digitalRead(joybutton);
}
void SetPass()
{
  
}
void PassCheck()
{
  
  if(passwordset == 1)
{
  if(login = 0)
  {
  display.setCursor(5,7);
  display.println("write a password now");
  delay(2000);
  inMenu = 5;
  }
}
static inline void fps(const int seconds){
  // Create static variables so that the code and variables can
  // all be declared inside a function
  static unsigned long lastMillis;
  static unsigned long frameCount;
  static unsigned int framesPerSecond;
  
  // It is best if we declare millis() only once
  unsigned long now = millis();
  if(FPStruefalse == 1)
  {
  frameCount ++;
  if (now - lastMillis >= seconds * 1000) {
    framesPerSecond = frameCount / seconds;
    display.setCursor(18,9);
    display.write(framesPerSecond);
    frameCount = 0;
    lastMillis = now;
  }
}
}

Biggest single problem seems to be an imbalance of { vs }.
Go into your IDE and press ctrl-T. Your code has now been formatted per a standard. Look at, for example, loop{}. Starts with a {. if you place your cursor on that {, then scroll down through the code, you'll find a corresponding }. IF they were matched, it would be in the leftmost column, but it's not.

Hint - loop() never closes out (no matching }) , so in this case, you'll never see a matching { for the one that loop() starts with.

Why don't you tell us what the problems were?

Were they all really related to the bootloader?

Missing } in the line 212.

Missing } in the line 349.

Missing } in the line 385.

Thanks for help!

I placed the missing } and marked the extra }. Does the code compile now?

#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <Wire.h>
// pin 7 - Serial clock out (SCLK)
// pin 6 - Serial data out (DIN)
// pin 5 - Data/Command select (D/C)
// pin 4 - LCD chip select (CS)
// pin 3 - LCD reset (RST)
Adafruit_SSD1306 display = Adafruit_SSD1306(3, 4, 5, 7, 6);
#define NUMFLAKES 8
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64
#define XPOS 0
#define YPOS 1
#define DELTAY 2
#define pinX A1  // ось X джойстика
#define pinY A2 // ось Y джойстика
#define joybutton A3 // кнопка джойстика
//переменные
int OnHello = 0;
int joy = 0;
unsigned long sleepMiliSEC = 0;
int sleepSEC = 0;
int inMenu = 0;
int menuCursor = 0;
int ChosedButton = 1;
boolean FPStruefalse = 0;
boolean passwordset = 0;
boolean login = 0;
int SettingsChosedButton = 1;
int SettingsmenuCursor = 3;
boolean sleeping = 0;
void setup()
{
   Serial.begin(9600);
   display.begin();
   sleepMiliSEC = millis();
   pinMode(1, INPUT);
   pinMode(pinX, INPUT);
   pinMode(pinY, INPUT);
   pinMode(joybutton, INPUT);
   digitalWrite(joybutton, HIGH);
   display.setTextSize(1);
   display.setTextColor(WHITE);
   display.setCursor(5, 5);
   display.println("Hello, Sasha!");
   PassCheck();
}

void loop()
{
   JoyStickControl();
   fps(1);
   //screen sleep:
   if (UsingButton == 0)
   {
      if (millis() - sleepMiliSEC > 1000)
      {
         sleepMiliSEC = millis();
         sleepSEC = sleepSEC + 1;
         if (sleepSEC >= 5)
            inMenu = 0;
         display.clearDisplay();
         sleeping = 1;
      }
   }
   if (UsingButton == 1)
   {
      if (sleepSEC >= 1)
      {
         sleepSEC = 0;
         sleepMiliSEC = 0;
      }
   }
   if (UsingButton == 1)
   {
      if (sleeping == 1)
      {
         GoodMorning();
      }
   }
   if (inMenu == 1)
   {
      if (pinY >= 300)
      {
         ChosedButton++;
         if (ChosedButton == 0)
         {
            ChosedButton = 3;
            display.write(" ");
            display.setCursor(10, 2);
            display.write(">");
            delay(250);
         }
         if (ChosedButton == 4)
         {
            ChosedButton = 1;
            display.write(" ");
            display.setCursor(2, 2);
            display.write(">");
            delay(250);
         }
         if (ChosedButton < 4)
         {
            if (ChosedButton > 0)
            {
               display.write(" ");
               display.setCursor(menuCursor + 4, 2);
               display.write(">");
               delay(250);
            }
         }
      }
      if (pinY >= -300)
      {
         ChosedButton--;
         if (ChosedButton == 0)
         {
            ChosedButton = 3;
            display.write(" ");
            display.setCursor(10, 2);
            display.write(">");
            delay(250);
         }
         if (ChosedButton == 4)
         {
            ChosedButton = 1;
            display.write(" ");
            display.setCursor(2, 2);
            display.write(">");
            delay(250);
         }
         if (ChosedButton < 4)
         {
            if (ChosedButton > 0)
            {
               display.write(" ");
               display.setCursor(menuCursor - 4, 2);
               display.write(">");
               delay(250);
            }
         }
      }
      if (UsingButton == 1)
      {
         if (ChosedButton == 1)
         {
            FlappyBird();
            inMenu = 2;
         }
         if (ChosedButton == 2)
         {
            inMenu = 3;
         }
         if (ChosedButton == 3)
         {
            inMenu = 4;
            SettingsMenu();
         }
      }
   }
} // ********************** added

void GoodMorning()
{
   display.setTextColor(WHITE);
   display.setCursor(5, 5);
   display.println("Good Morning!");
   delay(500);
   display.setCursor(5, 7);
   display.println("Drag a button to open menu!");
   SetPassCheck();
   // }
   if (UsingButton == 1)
   {
      display.clearDisplay();
      display.setTextSize(1);
      display.setCursor(2, 5);
      display.println("flappy bird");
      display.setCursor(6, 5);
      display.println("Заметки");
      display.setCursor(10, 5);
      display.println("Настройки");
      inMenu = 1;
      delay(200);
   }
} // ******************* added

void SettingsMenu()
{
   if (inMenu == 4)
   {
      display.clearDisplay();
      display.setCursor(3, 2);
      display.writeln("FPS:"FPStruefalse);
      display.setCursor(1, 2);
      display.write(">");
      if (pinY >= -300)
      {
         SettingsChosedButton--;
         display.write(" ");
         display.setCursor(1, SettingsmenuCursor - 2);
         if (SettingsmenuCursor == 0)
         {

            display.write(" ");
            display.setCursor(1, 6);
            SettingsmenuCursor = 3;
            display.write(">");
         }
      }
   }
}

void flappyBird(void)
{

   uint32_t tp = millis();

   float o_speed = 0.05;

   float bird_y = 0.5;
   float bird_vy = 0;
   float g = -1;

   uint8_t birdSize = 3;

   obstacle obs1;
   obstacle obs2;

   obs2.x += SCREEN_WIDTH / 2;

   int score = 0;

   bool won = false;

   while (true)
   {

      float dx = joyStick.x();
      float dy = joyStick.y();

      if (won)
      {
         dx = 0;
         dy = 0;
      }

      if (dx * dx + dy * dy > 0.5)
      {
         //jump
         bird_vy = 0.5;
      }

      float diff = (millis() - tp);
      tp = millis();

      bird_vy += diff * g / 500;
      bird_y += diff * bird_vy / 500;

      if (bird_y > 1)
      {
         bird_y = 1;
         bird_vy = 0;
      }
      if (bird_y < 0)
      {
         bird_y = 0;
         bird_vy = 0;
      }

      if (!won)
      {
         obs1.x -= diff * o_speed;
         obs2.x -= diff * o_speed;
      }

      if (obs1.x < -obs1.w / 2)
      {
         obs1.x = SCREEN_WIDTH + obs1.w / 2;
         obs1.h = (SCREEN_HEIGHT - obs1.slotSize) * (float)rand() / RAND_MAX;
         score++;
      }

      if (obs2.x < -obs2.w / 2)
      {
         obs2.x = SCREEN_WIDTH + obs2.w / 2;
         obs2.h = (SCREEN_HEIGHT - obs2.slotSize) * (float)rand() / RAND_MAX;
         score++;
      }

      if ((obs1.x > 30  - LOGO_WIDTH / 2) && (obs1.x < 30  + LOGO_WIDTH / 2))
      {
         bool collision = (bird_y * SCREEN_HEIGHT - LOGO_HEIGHT / 2 < SCREEN_HEIGHT - obs1.h - obs1.slotSize) || (bird_y * SCREEN_HEIGHT + LOGO_HEIGHT / 2 > SCREEN_HEIGHT - obs1.h);
         if (collision)
            won = true;
      }

      if ((obs2.x > 30  - LOGO_WIDTH / 2) && (obs2.x < 30  + LOGO_WIDTH / 2))
      {
         bool collision = (bird_y * SCREEN_HEIGHT - LOGO_HEIGHT / 2 < SCREEN_HEIGHT - obs2.h - obs2.slotSize) || (bird_y * SCREEN_HEIGHT + LOGO_HEIGHT / 2 > SCREEN_HEIGHT - obs2.h);
         if (collision)
            won = true;
      }

      display.clearDisplay();

      //display.drawCircle(30, SCREEN_HEIGHT*(1 - bird_y), birdSize, SSD1306_WHITE);

      display.drawBitmap(30  - LOGO_WIDTH / 2, SCREEN_HEIGHT * (1 - bird_y) - LOGO_HEIGHT / 2, birdpic_bmp, LOGO_WIDTH, LOGO_HEIGHT, 1);

      display.fillRect(obs1.x - obs1.w / 2 + 2, 0, obs1.w - 4, obs1.h, SSD1306_WHITE);
      display.fillRect(obs1.x - obs1.w / 2 + 2, obs1.h + obs1.slotSize, obs1.w - 4, SCREEN_HEIGHT - obs1.h - obs1.slotSize, SSD1306_WHITE);
      display.fillRect(obs1.x - obs1.w / 2, obs1.h - 4, obs1.w, 4, SSD1306_WHITE);
      display.fillRect(obs1.x - obs1.w / 2, obs1.h + obs1.slotSize, obs1.w, 4, SSD1306_WHITE);

      display.fillRect(obs2.x - obs2.w / 2 + 2, 0, obs2.w - 4, obs2.h, SSD1306_WHITE);
      display.fillRect(obs2.x - obs2.w / 2 + 2, obs2.h + obs2.slotSize, obs2.w - 4, SCREEN_HEIGHT - obs2.h - obs1.slotSize, SSD1306_WHITE);
      display.fillRect(obs2.x - obs2.w / 2, obs2.h - 4, obs2.w, 4, SSD1306_WHITE);
      display.fillRect(obs2.x - obs2.w / 2, obs2.h + obs2.slotSize, obs2.w, 4, SSD1306_WHITE);

      //drawObstacle(obs1);
      //drawObstacle(obs2);

      display.setTextSize(1);
      display.setTextColor(SSD1306_WHITE);
      display.setCursor(4, 4);
      display.print("score: ");
      display.print(score);
      display.display();

      if (UsingButton == 1())
         break;
   }
} // ************************** added

void JoyStickControl()
{
   boolean UsingButton = digitalRead(joybutton);
}

void SetPass()
{

}

void PassCheck()
{

   if (passwordset == 1)
   {
      if (login = 0)
      {
         display.setCursor(5, 7);
         display.println("write a password now");
         delay(2000);
         inMenu = 5;
      }
   }
   static inline void fps(const int seconds)
   {
      // Create static variables so that the code and variables can
      // all be declared inside a function
      static unsigned long lastMillis;
      static unsigned long frameCount;
      static unsigned int framesPerSecond;

      // It is best if we declare millis() only once
      unsigned long now = millis();
      if (FPStruefalse == 1)
      {
         frameCount ++;
         if (now - lastMillis >= seconds * 1000)
         {
            framesPerSecond = frameCount / seconds;
            display.setCursor(18, 9);
            display.write(framesPerSecond);
            frameCount = 0;
            lastMillis = now;
         }
      }
   }
} // ************************** added

That function does nothing. The variable goes out of scope as soon as the function exits so no longer exists.

In fact this code is a big mess and it's incomplete.

Where you found it?

#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <Wire.h>
// pin 7 - Serial clock out (SCLK)
// pin 6 - Serial data out (DIN)
// pin 5 - Data/Command select (D/C)
// pin 4 - LCD chip select (CS)
// pin 3 - LCD reset (RST)
Adafruit_SSD1306 display = Adafruit_SSD1306(3, 4, 5, 7, 6);
#define NUMFLAKES 8
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64
#define XPOS 0
#define YPOS 1
#define DELTAY 2
#define pinX A1      // ось X джойстика
#define pinY A2      // ось Y джойстика
#define joybutton A3 // кнопка джойстика
// переменные
int OnHello = 0;
int joy = 0;
unsigned long sleepMiliSEC = 0;
int sleepSEC = 0;
int inMenu = 0;
int menuCursor = 0;
int ChosedButton = 1;
boolean FPStruefalse = 0;
boolean passwordset = 0;
boolean login = 0;
int SettingsChosedButton = 1;
int SettingsmenuCursor = 3;
boolean sleeping = 0;
boolean UsingButton = false;

void SettingsMenu();
void flappyBird(void);
void JoyStickControl();
void SetPassCheck();
static inline void fps(const int seconds);
void GoodMorning();

void setup()
{
  Serial.begin(9600);
  display.begin();
  sleepMiliSEC = millis();
  pinMode(1, INPUT);
  pinMode(pinX, INPUT);
  pinMode(pinY, INPUT);
  pinMode(joybutton, INPUT);
  digitalWrite(joybutton, HIGH);
  display.setTextSize(1);
  display.setTextColor(WHITE);
  display.setCursor(5,5);
  display.println("Hello, Sasha!");
  PassCheck();
}

void loop()
{
  JoyStickControl();
  fps(1);
  // screen sleep:
  if(UsingButton == 0)
  {
    if (millis() - sleepMiliSEC > 1000)
    {
      sleepMiliSEC = millis();
      sleepSEC = sleepSEC + 1;
      if(sleepSEC >= 5)
      {
        inMenu = 0;
      }
      display.clearDisplay();
      sleeping = 1;
    }
  }
  if(UsingButton == 1)
  {
    if(sleepSEC >= 1)
    {
      sleepSEC = 0;
      sleepMiliSEC = 0;
    }
  }
  if(UsingButton == 1)
  {
    if(sleeping == 1)
    {
      GoodMorning();
    }
  }
  if(inMenu == 1)
  {
    if(pinY >= 300)
    {
      ChosedButton++;
      if(ChosedButton == 0)
      {
        ChosedButton = 3;
        display.write(" ");
        display.setCursor(10, 2);
        display.write(">");
        delay(250);
      }
      if(ChosedButton == 4)
      {
        ChosedButton = 1;
        display.write(" ");
        display.setCursor(2, 2);
        display.write(">");
        delay(250);
      }
      if(ChosedButton < 4)
      {
        if(ChosedButton > 0)
        {
          display.write(" ");
          display.setCursor(menuCursor + 4, 2);
          display.write(">");
          delay(250);
        }
      }
    }
    if(pinY >= -300)
    {
      ChosedButton--;
      if(ChosedButton == 0)
      {
        ChosedButton = 3;
        display.write(" ");
        display.setCursor(10, 2);
        display.write(">");
        delay(250);
      }
      if(ChosedButton == 4)
      {
        ChosedButton = 1;
        display.write(" ");
        display.setCursor(2, 2);
        display.write(">");
        delay(250);
      }
      if(ChosedButton < 4)
      {
        if(ChosedButton > 0)
        {
          display.write(" ");
          display.setCursor(menuCursor - 4, 2);
          display.write(">");
          delay(250);
        }
      }
    }
    if(UsingButton == 1)
    {
      if(ChosedButton == 1)
      {
        flappyBird();
        inMenu = 2;
      }
      if(ChosedButton == 2)
      {
        inMenu = 3;
      }
      if(ChosedButton == 3)
      {
        inMenu = 4;
        SettingsMenu();
      }
    }
  }
}

void GoodMorning()
{
  display.setTextColor(WHITE);
  display.setCursor(5,5);
  display.println("Good Morning!");
  delay(500);
  display.setCursor(5,7);
  display.println("Drag a button to open menu!");
  SetPassCheck();

  if(UsingButton == 1)
  {
    display.clearDisplay();
    display.setTextSize(1);
    display.setCursor(2,5);
    display.println("flappy bird");
    display.setCursor(6,5);
    display.println("Заметки");
    display.setCursor(10,5);
    display.println("Настройки");
    inMenu = 1;
    delay(200);
  }
}

void SettingsMenu()
{
  if(inMenu == 4)
  {
    display.clearDisplay();
    display.setCursor(3,2);
    display.write("FPS:");
    display.write(FPStruefalse);
    display.setCursor(1,2);
    display.write(">");
    if(pinY >= -300)
    {
      SettingsChosedButton--;
      display.write(" ");
      display.setCursor(1, SettingsmenuCursor - 2);
      if(SettingsmenuCursor == 0)
      {

        display.write(" ");
        display.setCursor(1, 6);
        SettingsmenuCursor = 3;
        display.write(">");
      }
    }
  }
}

void flappyBird(void)
{

  uint32_t tp = millis();

  float o_speed = 0.05;

  float bird_y = 0.5;
  float bird_vy = 0;
  float g = -1;

  uint8_t birdSize = 3;

  obstacle obs1;
  obstacle obs2;

  obs2.x += SCREEN_WIDTH / 2;

  int score = 0;

  bool won = false;

  while(true)
  {

    float dx = joyStick.x();
    float dy = joyStick.y();

    if(won)
    {
      dx = 0;
      dy = 0;
    }

    if (dx * dx + dy * dy > 0.5)
    {
      // jump
      bird_vy = 0.5;
    }

    float diff = (millis() - tp);
    tp = millis();

    bird_vy += diff * g / 500;
    bird_y += diff * bird_vy / 500;

    if(bird_y > 1)
    {
      bird_y = 1;
      bird_vy = 0;
    }
    if(bird_y < 0)
    {
      bird_y = 0;
      bird_vy = 0;
    }

    if(!won)
    {
      obs1.x -= diff * o_speed;
      obs2.x -= diff * o_speed;
    }

    if(obs1.x < -obs1.w / 2)
    {
      obs1.x = SCREEN_WIDTH + obs1.w / 2;
      obs1.h = (SCREEN_HEIGHT - obs1.slotSize) * (float)rand() / RAND_MAX;
      score++;
    }

    if(obs2.x < -obs2.w / 2)
    {
      obs2.x = SCREEN_WIDTH + obs2.w / 2;
      obs2.h = (SCREEN_HEIGHT - obs2.slotSize) * (float)rand() / RAND_MAX;
      score++;
    }

    if((obs1.x > 30  - LOGO_WIDTH / 2) && (obs1.x < 30  + LOGO_WIDTH / 2))
    {
      bool collision = (bird_y * SCREEN_HEIGHT - LOGO_HEIGHT / 2 < SCREEN_HEIGHT - obs1.h - obs1.slotSize) || (bird_y * SCREEN_HEIGHT + LOGO_HEIGHT / 2 > SCREEN_HEIGHT - obs1.h);
      if(collision)
      {
        won = true;
      }
    }

    if((obs2.x > 30  - LOGO_WIDTH / 2) && (obs2.x < 30  + LOGO_WIDTH / 2))
    {
      bool collision = (bird_y * SCREEN_HEIGHT - LOGO_HEIGHT / 2 < SCREEN_HEIGHT - obs2.h - obs2.slotSize) || (bird_y * SCREEN_HEIGHT + LOGO_HEIGHT / 2 > SCREEN_HEIGHT - obs2.h);
      if(collision)
      {
        won = true;
      }
    }

    display.clearDisplay();

    // display.drawCircle(30, SCREEN_HEIGHT*(1 - bird_y), birdSize, SSD1306_WHITE);

    display.drawBitmap(30  - LOGO_WIDTH / 2, SCREEN_HEIGHT * (1 - bird_y) - LOGO_HEIGHT / 2, birdpic_bmp, LOGO_WIDTH, LOGO_HEIGHT, 1);

    display.fillRect(obs1.x - obs1.w / 2 + 2, 0, obs1.w - 4, obs1.h, SSD1306_WHITE);
    display.fillRect(obs1.x - obs1.w / 2 + 2, obs1.h + obs1.slotSize, obs1.w - 4, SCREEN_HEIGHT - obs1.h - obs1.slotSize, SSD1306_WHITE);
    display.fillRect(obs1.x - obs1.w / 2, obs1.h - 4, obs1.w, 4, SSD1306_WHITE);
    display.fillRect(obs1.x - obs1.w / 2, obs1.h + obs1.slotSize, obs1.w, 4, SSD1306_WHITE);

    display.fillRect(obs2.x - obs2.w / 2 + 2, 0, obs2.w - 4, obs2.h, SSD1306_WHITE);
    display.fillRect(obs2.x - obs2.w / 2 + 2, obs2.h + obs2.slotSize, obs2.w - 4, SCREEN_HEIGHT - obs2.h - obs1.slotSize, SSD1306_WHITE);
    display.fillRect(obs2.x - obs2.w / 2, obs2.h - 4, obs2.w, 4, SSD1306_WHITE);
    display.fillRect(obs2.x - obs2.w / 2, obs2.h + obs2.slotSize, obs2.w, 4, SSD1306_WHITE);

    // drawObstacle(obs1);
    // drawObstacle(obs2);

    display.setTextSize(1);
    display.setTextColor(SSD1306_WHITE);
    display.setCursor(4, 4);
    display.print("score: ");
    display.print(score);
    display.display();

    if(UsingButton == 1 ())
    {
      break;
    }
  }
}
void JoyStickControl()
{
  UsingButton = digitalRead(joybutton);
}
void SetPassCheck()
{

}
void PassCheck()
{

  if(passwordset == 1)
  {
    if(login = 0)
    {
      display.setCursor(5,7);
      display.println("write a password now");
      delay(2000);
      inMenu = 5;
    }
  }
}

static inline void fps(const int seconds)
{
  // Create static variables so that the code and variables can
  // all be declared inside a function
  static unsigned long lastMillis;
  static unsigned long frameCount;
  static unsigned int framesPerSecond;

  // It is best if we declare millis() only once
  unsigned long now = millis();
  if(FPStruefalse == 1)
  {
    frameCount++;
    if (now - lastMillis >= seconds * 1000)
    {
      framesPerSecond = frameCount / seconds;
      display.setCursor(18,9);
      display.write(framesPerSecond);
      frameCount = 0;
      lastMillis = now;
    }
  }
}

Thank you, yes errors now solved.

It's a local variable being used as global.

I know is the code is incomplete, i tried it because i just wanted to see im doing code right or not

Without complete code we can't compile it and can't help you find more errors.

There's some misspelling, sometimes you are using SetPassCheck and other PassCheck and so on.

void JoyStickControl()
{
   boolean UsingButton = digitalRead(joybutton);
}

Sorry, that makes no sense to me. Please explain how that works.

The return type is void so the function returns nothing. Even if there was a return type, there is no return sratement to give the return type a value.

In fact it's an useless function for now because it could be done in this way.

UsingButton = digitalRead(joybutton);

if (UsingButton == 1)
{
 break;
}

Look my screenshot and you will understand.

thank you people for help, this functions need to do password on arduino - usingbutton says if i clicked something. function setpasscheck need to setpassword, and passcheck need to input it and continue. i read everything you wroted and i solved this things.
Im trying to do something like phone but it cant call, there is some programs like calc or games.

For me C++ is a new language. I did scripts on C#(unity) before arduino and I did this project on the emulator of arduino nano, because i dont have an arduino now (i buy it and delivery is not so fast). And when i turn on arduino uno display is on for 2 seconds, and here is no image after. Can you help me please?
Thanks for help!
Here is video: 2023 03 03 22 44 38 - YouTube
Here is script:

#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
Adafruit_SSD1306 display(128, 64, &Wire, 4);

#define pinX A0  // ось X джойстика
#define pinY A1 // ось Y джойстика
#define joybutton 3 // кнопка джойстика
//переменные
int OnHello = 0;
unsigned long sleepMiliSEC = 0;
int sleepSEC = 0;
int inMenu = 0;
int menuCursor = 0;
int ChosedButton = 1;
// boolean FPStruefalse = 0;
bool passwordset = 0;
bool login = 0;
int SettingsChosedButton = 1;
int SettingsmenuCursor = 3;
bool sleeping = 0;
bool UsingButton;
void setup()
{
   Serial.begin(9600);
   display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
   sleepMiliSEC = millis();
   pinMode(pinX, INPUT);
   pinMode(pinY, INPUT);
   pinMode(joybutton, INPUT);
   display.setTextSize(1, 1);
   display.setTextColor(SSD1306_WHITE);
   display.setCursor(20, 20);
   display.println("Hello, Sasha!");
   PassCheck();
}
void loop()
{
   display.display();
   UsingButton = digitalRead(joybutton);
    int X = analogRead(pinX);              // считываем значение оси Х
  int Y = analogRead(pinY);              // считываем значение оси Y
   //screen sleep:
   if (UsingButton == 0)
   {
      if (millis() - sleepMiliSEC > 1000)
      {
         sleepMiliSEC = millis();
         sleepSEC = sleepSEC + 1;
         if (sleepSEC >= 5)
            inMenu = 0;
         display.clearDisplay();
         sleeping = 1;
      }
   }
   if (UsingButton == 1)
   {
      if (sleepSEC >= 1)
      {
         sleepSEC = 0;
         sleepMiliSEC = 0;
      }
   }
   if (UsingButton == 1)
   {
      if (sleeping == 1)
      {
         GoodMorning();
      }
   }
   if (inMenu == 1)
   {
      if (pinY >= 300)
      {
         ChosedButton++;
         if (ChosedButton == 0)
         {
            ChosedButton = 3;
            display.write(" ");
            display.setCursor(10, 2);
            display.write(">");
            delay(250);
         }
         if (ChosedButton == 4)
         {
            ChosedButton = 1;
            display.write(" ");
            display.setCursor(2, 2);
            display.write(">");
            delay(250);
         }
         if (ChosedButton < 4)
         {
            if (ChosedButton > 0)
            {
               display.write(" ");
               display.setCursor(menuCursor + 4, 2);
               display.write(">");
               delay(250);
            }
         }
      }
      if (pinY >= -300)
      {
         ChosedButton--;
         if (ChosedButton == 0)
         {
            ChosedButton = 3;
            display.write(" ");
            display.setCursor(10, 2);
            display.write(">");
            delay(250);
         }
         if (ChosedButton == 4)
         {
            ChosedButton = 1;
            display.write(" ");
            display.setCursor(2, 2);
            display.write(">");
            delay(250);
         }
         if (ChosedButton < 4)
         {
            if (ChosedButton > 0)
            {
               display.write(" ");
               display.setCursor(menuCursor - 4, 2);
               display.write(">");
               delay(250);
            }
         }
      }
      if (UsingButton == 1)
      {
         if (ChosedButton == 1)
         {
            inMenu = 2;
         }
         if (ChosedButton == 2)
         {
            inMenu = 3;
         }
         if (ChosedButton == 3)
         {
            inMenu = 4;
            SettingsMenu();
         }
      }
   }
}

void GoodMorning()
{
   display.setTextColor(WHITE);
   display.setCursor(5, 5);
   display.println("Good Morning!");
   delay(500);
   display.setCursor(5, 7);
   display.println("Drag a button to open menu!");
   PassCheck();
   // }
   if (UsingButton == 1)
   {
      display.clearDisplay();
      display.setTextSize(1);
      display.setCursor(2, 5);
      display.println("flappy bird");
      display.setCursor(6, 5);
      display.println("Заметки");
      display.setCursor(10, 5);
      display.println("Настройки");
      inMenu = 1;
      delay(200);
   }
} 

void SettingsMenu()
{
   if (inMenu == 4)
   {
      display.clearDisplay();
      display.setCursor(3, 2);
     // display.writeln("FPS:"FPStruefalse);
      display.setCursor(1, 2);
      display.write(">");
      if (pinY >= -300)
      {
         SettingsChosedButton--;
         display.write(" ");
         display.setCursor(1, SettingsmenuCursor - 2);
         if (SettingsmenuCursor == 0)
         {

            display.write(" ");
            display.setCursor(1, 6);
            SettingsmenuCursor = 3;
            display.write(">");
         }
      }
   }
}

void SetPass()
{

}

void PassCheck()
{
   if (passwordset == 1)
   {
      if (login == 0)
      {
         display.setCursor(5, 7);
         display.println("write a password now");
         display.display();
         delay(2000);
         inMenu = 5;
      }
   }
   if(passwordset == 0)
   {
     
   }
}


Would that be the two second delay in PassCheck?

yes, there will be something like animation with keyboard after it

i need to see a text "write a password now" and it will be solved