aUCBLogo Demos and Tests / moonphases
to moonphases
hideTurtle
setScreenColor 0
perspective
setPenColor "grey ;"white
setLightSpecular RGB 1 1 1
setMaterialSpecular RGB 1 1 1
setMaterialShininess 5
t=Texture loadImage "moon.jpg
(Sphere 250 400 400)
rotateScene
end
to rotateScene [dphi 1] ;a bit modified from the library procedure
local [eye phi ddphi theta dtheta center upvector r dr]
eye=Array 3
theta=0
dtheta=5
center={0 0 0}
upvector={0 1 0}
phi=0
ddphi=dphi/3
r=500
dr=1.1
pr [left, right changes rotation speed, uP down set Pitch, ESC exits]
dispatchMessages
forever
[ eye.1=r*(Cos theta)*Sin phi
eye.2=r* Sin theta
eye.3=r*(Cos theta)*Cos phi
setEye eye center upvector
setLightPos {0 0 1000}
redraw
phi=phi+dphi
if Key?
[ dispatchMessages
local [ch]
ch=readChar
ifElse ch==Char 255
[ ch=readCharExt
if ch==WXK_RIGHT [dphi=dphi+ddphi]
if ch==WXK_LEFT [dphi=dphi-ddphi]
if ch==WXK_UP [theta=theta+dtheta]
if ch==WXK_DOWN [theta=theta-dtheta]
if ch==WXK_PRIOR [r=r/dr]
if ch==WXK_NEXT [r=r*dr]
][
if ch==Char 27 [stop]
if ch=="+ [r=r-dr]
if ch=="- [r=r+dr]
]
]
]
end