from math import * from kandinsky import * from ion import * from time import monotonic,sleep sw,sh=15,15 # street dimensions cw,ch=13,13 # cell dimensions ct=[ # cell types [cw,ch]+[2]*(cw*ch), [10,10, 1,1,1,1,1,1,1,1,1,1, 1,0,0,0,0,0,0,0,0,0, 1,0,0,0,0,0,0,0,0,1, 1,0,0,0,0,0,0,0,0,0, 1,0,0,0,0,0,0,0,0,1, 1,0,0,0,0,0,0,0,0,0, 1,0,0,0,0,0,0,0,0,1, 1,0,0,0,0,0,0,0,0,0, 1,0,0,0,0,0,0,0,0,1, 1,0,1,0,1,0,1,0,1,0 ], [13,13, 0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,1,1,1,1,1,0,0,0,0, 0,0,0,1,0,0,0,0,0,1,0,0,0, 0,0,0,1,0,1,1,1,0,1,0,0,0, 0,0,0,1,0,1,1,1,0,1,0,0,0, 0,0,0,1,1,1,1,1,1,1,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0, ], [13,13, 0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,1,1,1,1,1,0,0,0,0, 0,0,0,1,0,0,0,0,0,1,0,0,0, 0,0,1,0,0,0,0,0,0,0,1,0,0, 0,0,1,0,1,1,0,1,1,0,1,0,0, 0,0,1,0,0,0,0,0,0,0,1,0,0, 0,0,1,0,0,1,1,1,0,0,1,0,0, 0,0,1,0,0,1,1,1,0,0,1,0,0, 0,0,1,1,1,1,1,1,1,1,1,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0, ], [13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t(t,x,y): # render tile c=ct[t] for px in range(c[0]): for py in range(c[1]): pv=cl[c[2+px+(c[1]-py-1)*c[0]]] if pv:set_pixel(px+x,-py+y,pv) def ds(): # draw screen for px in range(sw): for py in range(sh): rt(c[px+py*sw],px*cw,(py+2)*ch) s = monotonic() ds() draw_string(str(monotonic()-s),0,50) while not keydown(KEY_OK): sleep(0.1) set_pixel(0,0,(255,0,0))