from math import * from kandinsky import * from kandinsky import fill_rect as fill from ion import * from time import * from random import * p_dir=randint(1,4) left=False right=False bg="blue" x=100 y=100 c1=(255,)*3 c2=(255,0,0) fill_rect(0,0,322,222,bg) while 1: fill_rect(x,y,10,10,c1) if p_dir==1: sleep(.005) x-=1 fill_rect(x+11,y,1,10,bg) if p_dir==2: sleep(.005) x+=1 fill_rect(x-1,y,1,10,bg) if p_dir==3: sleep(.005) y-=1 fill_rect(x,y+10,10,1,bg) if p_dir==4: sleep(.005) y+=1 fill_rect(x,y-1,10,1,bg) if keydown(KEY_OK): sleep(0.05) p_dir=randint(1,4) if x<1: x=1 p_dir=choice([2,3,4]) if x+10>321: x=321-10 p_dir=choice([1,3,4]) if y<1: y=1 p_dir=choice([1,2,4]) if y+10>222: y>222 p_dir=choice([1,2,3])