aUCBLogo Demos and Tests / dragonflies
be dragonflies
cs home wrap
createTexture=false ;true
ifelse createTexture
[ maxx=300
setScreenRange -maxx -maxx maxx maxx
][ maxx=400
]
rerandom
repeat 100
[ make "red rnd
make "green rnd
make "blue rnd
make "x -maxx+random maxx*2
make "y -300+random 600
make "h random 360
setpc rgb :red :green :blue
pu setpos (list :x :y)
seth :h
dragonfly random 100
]
if createTexture
[ setSaveSize list maxx*2 maxx*2
saveScreen "dragonflies.png
setSaveSize [800 600]
setScreenRange -400 -300 400 300
]
end
be dragonfly :size
make "xx first pos
make "yy last pos
make "hh heading
setpensize [1 1]
pu dragonfly_body
be dragonfly_body
ht
pu
setpos (list :xx :yy)
seth :hh
fd :size/2
make "rm :size/20
make "f 1
repeat int :size*0.4 [pd ellipse :rm*:f :size/40
pu bk :size/40
make "f :f*cos repcount]
dragonfly_tail
end
be dragonfly_tail
make "side random 2
ifelse :side==1
[ dragonfly_righttail
]
[ dragonfly_lefttail
]
end
be dragonfly_righttail
pu seth :hh+180 setpensize [2 2]
repeat int :size*0.6 [pd fd 1 rt 0.4]
dragonfly_rightantenna
end
be dragonfly_lefttail
pu seth :hh+180 setpensize [2 2]
repeat int :size*0.6 [pd fd 1 lt 0.4]
dragonfly_rightantenna
end
be dragonfly_rightantenna
pu setpos (list :xx :yy) seth :hh
fd :size/2
setpensize [1 1]
make "ang 1
repeat 22 [pd fd :size/100 rt :ang make "ang :ang*1.2]
dragonfly_leftantenna
end
be dragonfly_leftantenna
pu setpos (list :xx :yy) seth :hh
fd :size/2
setpensize [1 1]
make "ang 1
repeat 22 [pd fd :size/100 lt :ang make "ang :ang*1.2]
dragonfly_rightwing
end
be dragonfly_rightwing
pu setpos (list :xx :yy) seth :hh fd :size/4
seth :hh+60 pd fd :size arc2 200 :size*0.2 fd :size
seth :hh+90
fd :size*0.8
arc2 200 (:size*0.8)*0.2
fd :size*0.8
dragonfly_leftwing
end
be dragonfly_leftwing
pu setpos (list :xx :yy) seth :hh fd :size/4 bk :size/22.5
seth :hh+280 pd
fd :size
arc2 200 :size*0.2
fd :size
pu setpos (list :xx :yy) seth :hh fd :size/4 bk :size/12.5
seth :hh+250 pd fd :size*0.8
arc2 200 (:size*0.8)*0.2
fd :size*0.8
end
end