from Lcd import UniversalLCD
import machine
from time import sleep
# Notice we simply skip the d0-d3 arguments
lcd = UniversalLCD(
rs=8, e=9,
d4=10, d5=11, d6=12, d7=13,
rows=4, cols=20
)
button = machine.Pin(28, machine.Pin.IN, machine.Pin.PULL_UP)
icon1 = [
0b11111,
0b10011,
0b10011,
0b11111,
0b11111,
0b10000,
0b10000,
0b11111
]
icon2 = [
0b11100,
0b00100,
0b00100,
0b11100,
0b11100,
0b00100,
0b00100,
0b11100
]
spike1 = [
0b00110,
0b00110,
0b01111,
0b01111,
0b11111,
0b11111
]
lcd.create_char(0, icon1)
lcd.create_char(1, icon2)
lcd.create_char(2, spike1)
cubeUp = 0
cubeY = 0
spikes = [10, 20, 30]
while True:
lcd.clear()
lcd.putstr("Geometry Dash")
if cubeY == 0:
lcd.move_to(3, 0)
elif cubeY == 1:
lcd.move_to(2, 0)
else:
lcd.move_to(1, 0)
lcd.putstr(chr(0) + chr(1))
if button.value() == 0 and cubeY == 0:
print('jump')
cubeUp = 1
cubeY = 1
elif cubeUp == 1 and cubeY == 1:
cubeY = 2
elif cubeY == 2:
cubeY = 1
cubeUp = 0
elif cubeY == 1 and cubeUp == 0:
cubeY = 0
for spike in spikes:
if spike > -1 and spike < 21:
lcd.move_to(3, spike)
lcd.putstr(chr(2))
if spike == (0 or 1) and cubeY == 0:
exit()
for i in range(len(spikes)):
spikes[i - 1] = spikes[i - 1] - 1
sleep(0.1)