#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);
int x1=15; //Position I
int x2=0; //reset I bei 16
bool x3=HIGH; //Position Ball
long t1=0; //merker scrollen
long t2=0; //merker Jump aktivieren
long x4=300; //Geschwindigkeit I
long x5=0; //Verkürzung jump & jump delay
void setup() {
pinMode(8, INPUT);
lcd.init();
lcd.backlight();
}
void loop() {
if(x3==HIGH && x1==0){
lcd.clear();
lcd.setCursor(5,0);
lcd.print("GAME");
lcd.setCursor(5,1);
lcd.print("OVER");
delay(1000);
}
else{
if(digitalRead(8)==HIGH && (millis()-t2)>(1200-x5)){ //Jump
x3=LOW;
t2=millis();
}
if(x3==LOW && (millis()-t2)>=(900-x5)){x3=HIGH;} //Fall
if((millis()-t1)>=x4){ //delay
lcd.clear();
lcd.setCursor(1,x3);
lcd.print("o");
lcd.setCursor(x1,1);
lcd.print("I");
if(x2<=15){x1=x1-1; x2++;}
if(x2==16){x1=15; x2=0;}
if(x4>50){x4=x4-1; x5=x5+2;}
t1=millis();
}
}
}