from schoginitoys import *
# Initialize starting position (x, y)
x, y = 16, 4
# Main loop
display_reset()
while True:
# Clear display
# display.fill(0)
# Read button states and update position
if Config.up and y > 0:
display.set_pixel(x, y, 0) #old led
y -= 1
time.sleep(0.5)
Config.up = False
if Config.down and y < 7:
display.set_pixel(x, y, 0) #old led
y += 1
time.sleep(0.5)
Config.down = False
if Config.left and x > 0:
display.set_pixel(x, y, 0) #old led
x -= 1
time.sleep(0.5)
Config.left = False
else:
if Config.left and x == 0: #left end
scroll("Left end, exiting!")
break
if Config.right and x < 31:
display.set_pixel(x, y, 0) #old led
x += 1
time.sleep(0.5)
Config.right = False
display.set_pixel(x, y, 1) #new led
display.show()
time.sleep(0.5)
if Config.button_pressed: # Back
break