from machine import Pin,SoftI2C
import ssd1306
form time import sleep
import gfx
import random
i2c=SoftI2C(scl=Pin(22),sda=Pin(21))
ow=128
oh=64
oled=ssd1306.SSD1306_I2C(ow,oh,i2c)
graphics=gfx.GFX(ow,oh,oled.pixel)
x=0
y=0
sign=-1
dira=-1
up=Pin(18,Pin.IN,Pin.PULL_UP)
west=Pin(5,Pin.IN,Pin.PULL_UP)
down=Pin(17,Pin.IN,Pin.PULL_UP)
east=Pin(16,Pin.IN,Pin.PULL_UP)
ball_x=20
ball_y=10
oled.text("*",ball_x,ball_y)
oled.show()
score=0
oled.text("S:",100,0)
oled.text(str(score),120,0)
oled.show()
for i in range(5):
oled.text(","x,y)
oled.show()
x+=4
def clear_rectangle(x1,y1,width,height):
for y in range(y1,y1+height):
for x in range(x1,x1+width):
oled.pixel(x,y,0)
oled.show()
while True:
if ball_x in (x,x-1,x-2,x-3,x-4,x-5,x+5,x+4,x+3,x+2,x+1) and ball_y
in(y,y-5,y-4,y-3,y-2,y-1,y+5,y+4,y+3,y+2,y+1):
score+=1
clear_rectangle(ball+x,ball_y,10,10)
ball_x=random.randint(3,125)
ball_y=random.randint(3,60)
oled.text("x",ball_x,ball_y)
clear.rectangle(120,0,10,10)
oled.text(str(score),120,0)
oled.show()
print(east.value())
if not up.value():
sign=1
dira=0
elif not east.value():
sign=0
dira=0
elif not west.value():
sign=1
dira=1
elif not down.value():
sign=0
dira=1