Problem 8b.#seed import math def random (): b= (334290+3*g.getTime(4)*g.getTime(3)) print int(b%100) return int(b%100) def plant (x,y): k=(random()%4) while k > 0: e=(1+(random())%2) b=e while b>0: g.norefresh() c=int((25-e)*(math.cos(math.pi/(3+random()%3.0)+(math.pi/4)))) g.pause(3) d=int((25-e)*(math.sin(math.pi/(3+random()%3.0)+(math.pi/4)))) g.line (x,y,(x+c),(y+d)) i = (x+c) j = (y+d) g.refresh() l= (random()%(2*e)) while l>0: c=int((20-e)*(math.cos(math.pi/(2+random()%5.0)+(math.pi/4)))) g.pause(3) d=int((20-e)*(math.sin(math.pi/(2+random()%5.0)+(math.pi/4)))) g.line (i,j,(i+c),(j+d)) l=(l-1) b=(b-1) k=(k-1) while 1: if g.getMouse(3)==100: plant(g.getMouse(1), g.getMouse(2))-gary escudero |
|