aUCBLogo Demos and Tests / snowygarden2
to snowygarden2
setUpdateGraph false
noRefresh
hideTurtle
clearScreen
setScreenColor RGB 0.7 0.7 1
disableLineSmooth
WindowMode
snowland
forest
garden
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 snowland
usetXY -400 0
setHeading 90
setPenColor RGB 1 1 1
randomWalk 2000
usetXY -300 -300
setFloodColor RGB 1 1 1
fill
usetXY -400 -300
snowlandbm=BitCopy 800 600
end
to forest
r=random IntMax
forests=20
forestbmp=(Array forests 0)
for [i 0 forests-1]
[ (reRandom r)
clearScreen
usetXY -400 -300
BitPaste snowlandbm
repeat 20
[ usetXY (rnd-0.5)*800 rnd*50-100
(tree3 7 50+random 80 1*sin 360*i/forests)
setHeading 0
dispatchMessages
if Key? [break]
]
updateGraph
usetXY -400 -300
forestbmp.i=BitCopy 800 600
]
end
to garden
gardens=23
gardenbmp=(Array gardens 0)
for [i 0 gardens-1]
[ setScreenColor RGB 1 1 1
clearScreen
usetXY -300 -200
house 300
usetXY 100 -200
(tree2 8 100 1*sin 360*i/gardens)
updateGraph
usetXY -400 -300
gardenbmp.i=BitCopy 800 600
BitMakeTransparent gardenbmp.i RGB 1 1 1
dispatchMessages
if Key? [break]
]
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
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.2)*20
]
setScreenColor RGB 0 0 0
setPenColor RGB 0.9 0.9 0.9
j=0
k=0
while [not Key?]
[ BitPasteTo bm forestbmp.j 0 0
j=mod j+1 forests
BitPasteTo bm gardenbmp.k 0 0
k=mod k+1 gardens
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.2)*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