from math import * from kandinsky import * from time import * screen_width = 320 screen_height=222 map=[ [1,1,1,1,1], [1,0,0,0,1], [1,0,0,0,1], [1,0,0,0,1], [1,1,1,1,1] ] def sizeList(liste): count=0 for i in liste: count+=1 return count def checkIn(x,y): ymap=-sizeList(map)/2 for layer in map: xmap=-sizeList(map[0])/2 for i in layer: if i==1: if x>xmap and x<xmap+1: if y>ymap and y<ymap+1: return True xmap+=1 ymap+=1 return False alr=0 for i in range(360): i = i * pi / 180 addx=sin(i) addy=cos(i) rayx=0 rayy=0 fill_rect(int(rayx*64+screen_width/2),int(rayy*44.4+0.5*screen_height),2,2,color(0,0,255)) touched=False while touched!=True: rayx+=addx * 0.15 rayy+=addy * 0.15 fill_rect(int(rayx*64+screen_width/2),int(rayy*44.4+0.5*screen_height),2,2,color(0,0,255)) #sleep(0.01) if checkIn(rayx,rayy): alr+=1 draw_string(str(alr),0,0) touched=True fill_rect(int(rayx*64+screen_width/2),int(rayy*44.4+0.5*screen_height),4,4,color(255,0,0))