#include <LiquidCrystal.h>

#define push  13
#define buzzer 14

LiquidCrystal lcd(12, 11, 10, 9, 8, 7);

uint8_t rex1[8]={0x07, 0x17, 0x16, 0x1F, 0x02, 0x02, 0x03, 0x00};        
uint8_t rex2[8]={0x07, 0x17, 0x16, 0x1F, 0x08, 0x08, 0x08, 0x0C};        
uint8_t cactus[8]={0x00, 0x14, 0x14, 0x15, 0x1F, 0x04, 0x04, 0x0E};        
uint8_t ave[8]={0x00,0x08,0x1F,0x06,0x04,0x00,0x00,0x00};

void setup() {
  // put your setup code here, to run once:
  pinMode(push, INPUT_PULLUP);
  pinMode(buzzer, OUTPUT);
  lcd.begin(16, 2);

  lcd.createChar(0, rex1);
  lcd.createChar(1, rex2);
  lcd.createChar(2, cactus);
  lcd.createChar(3, ave);
  lcd.home();

  lcd.setCursor(3, 0);
  lcd.print("T-Rex Game");
  delay(2500);
}

void loop() {
  // put your main code here, to run repeatedly:
  lcd.clear();
  lcd.setCursor(2, 0);
  lcd.print("Push to Start");
  while(digitalRead(push) == 1);
  delay(100);
  lcd.clear();

  int cactus = 14;
  int ave = 15;

  while(1){
    if(digitalRead(push) == 0){
      lcd.setCursor(0, 1);   //
      lcd.print("   ");
      lcd.setCursor(0, 0);
      lcd.write((byte) 0);
    
    //if ( ave == 0){
      //lcd.clear();
      //lcd.setCursor(3,0);
      //lcd.print("GAME OVER");
     // }
      lcd.setCursor(cactus, 1);
      lcd.write((byte) 2);
      delay(100);
      lcd.setCursor(0, 0);
      lcd.write((byte) 1);
      lcd.setCursor(cactus, 1);
      lcd.print("  ");
      delay(100);
      cactus -= 1;
      if(cactus < 0){
        cactus = 15;   //para que avance el cactus
      }
    }else{
      lcd.setCursor(0, 1);  
      lcd.print("   ");
       lcd.setCursor(1, 0);
      lcd.write((byte) 0);
      lcd.setCursor(cactus, 1);
      lcd.write((byte) 2);
      delay(100);
      lcd.setCursor(0, 1);
      lcd.write((byte) 1);
      lcd.setCursor(cactus, 1);
      lcd.print("  ");
      delay(100);
      cactus -= 1;
      ave -= 1;
      if(cactus < 0){
        cactus = 15;   //para que avance el cactus
      }
      if(cactus == 0){
        lcd.clear();
        lcd.setCursor(3, 1);
        lcd.write((byte) 3);
        delay(500);
        lcd.clear();
        lcd.setCursor(3, 0);
        lcd.print("GAME OVER");
        tone(buzzer,100);
        delay(200);
        tone(buzzer, 0);
        lcd.write(" ");
        lcd.clear(); 
        lcd.print(" Continue in 3");
        lcd.setCursor(1,0);
        delay(600);
        lcd.print("Continue in 2");
        lcd.setCursor(1,0);
        delay(600);
        lcd.print("Continue in 1");
        lcd.setCursor(1,0);
        delay(600);
        break; //rompe el ciclo
      }
    }
    
  }
}

  
Loading
pi-pico-w