aUCBLogo Demos and Tests / snowygarden
to snowygarden
hideTurtle
clearScreen
setScreenColor RGB 0.7 0.7 1
disableLineSmooth
WindowMode
usetXY -400 0
setHeading 90
setPenColor RGB 1 1 1
randomWalk 2000
usetXY -300 -300
setFloodColor RGB 1 1 1
fill
forest
usetXY -300 -200
house 300
usetXY 100 -200
tree2
snow
end
to usetXY x y
PenUp setXY x y PenDown
setHeading 0
end
to randomWalk l
fd 1
rt (rnd-0.5)*1
if l > 0 [randomWalk l-1]
end
to forest
repeat 20
[ usetXY (rnd-0.5)*800 rnd*50-100
(tree3 7 50+random 80)
setHeading 0
updateGraph
]
end
to house s
setPenColor RGB 0.5 0.1 0
setPenSize (List s s)/200
forward s/2
right 45
fd s/sqrt 2
rt 90
fd s/sqrt 2
rt 45
fd s/2
rt 90
fd s
p=Pos
rt 90+45
PenUp fd s/5/sqrt 2 left 45 PenDown
setFloodColor RGB 1 0.5 0.5
fill
drawWindow s/4
PenUp rt 90 fd s*0.6 left 90 PenDown
drawWindow s/4
pu left 90 fd s*0.25 rt 90 fd s/2.2 pd
drawWindow s/5
PenUp setPos p PenDown
rt 90
fd s/2-s/14
left 90
pu fd s/50 pd
drawDoor s/3.5
end
to drawWindow s
repeat 2
[ fd s rt 90 fd s*0.9 rt 90
]
PenUp rt 45 fd s/sqrt 2 PenDown
setFloodColor RGB 0.5 0.5 1
fill
PenUp back s/sqrt 2 lt 45 PenDown
end
to drawDoor s
repeat 2
[ fd s rt 90 fd s*0.6 rt 90
]
PenUp rt 45 fd s/sqrt 2 PenDown
setFloodColor RGB 0.5 0.3 0.3
fill
PenUp back s/sqrt 2 lt 45 PenDown
end
to snow
usetXY -400 -300
bm=BitCopy 800 600
bkgd=BitCopy 800 600
setUpdateGraph false
noRefresh
setPenSize [2 2]
flakes=500
p=Array flakes
z=Array flakes
v=Array flakes
o=Array flakes
ov=Array flakes
repeat flakes
[ i=repcount
p.i=(List (rnd-0.5)*800 (rnd-0.5)*600 rnd*2000+100)
v.i=(List (rnd-0.5)*4 -1-rnd*4 (rnd-0.5)*4)
o.i=rnd*360
ov.i=(rnd-0.5)*20
]
setScreenColor RGB 0 0 0
setPenColor RGB 0.9 0.9 0.9
while [not Key?]
[ BitPasteTo bm bkgd 0 0
clearScreen
PenUp
p=p+v
o=o+ov
repeat flakes
[ i=repcount
if p.i.2 < -300 or2 p.i.3 < 30
[ p.i=(List (rnd-0.5)*800 320 rnd*2000+100)
v.i=(List (rnd-0.5)*4 -rnd*4 (rnd-0.5)*4)
o.i=rnd*360
ov.i=(rnd-0.5)*20
]
setXY p.i.1 p.i.2
drawFlake o.i 1000/p.i.3
]
usetXY -400 -300
snowbm=BitCopy 800 600
BitMakeTransparent snowbm RGB 0 0 0
BitPasteTo bm snowbm 0 0
BitPasteFast bm
]
refresh
end
to drawFlake o s
setH o
repeat 3
[ back s
PenDown
fd s*2
PenUp
back s
rt 60
]
Penup
end