aUCBLogo Demos and Tests / throwcoin
to throwcoin
coin1=loadImage "coin1_64x64.png
coin2=loadImage "coin2_64x64.png
white=BitPixel coin1 0 0
BitMakeTransparent coin1 white
BitMakeTransparent coin2 white
for [a 1 360 1]
[ for [r 28 34 0.5]
[ x=int 32+r*sin a
y=int 32+r*cos a
c=reRGB BitPixel coin1 x y
BitSetPixel coin1 x y RGBA c.1 c.2 c.3 0.0
]
]
for [a 1 360 1]
[ for [r 28 34 0.5]
[ x=int 32+r*sin a
y=int 32+r*cos a
c=reRGB BitPixel coin2 x y
BitSetPixel coin2 x y RGBA c.1 c.2 c.3 0.0
]
]
coin1tex=Texture coin1
coin2tex=Texture coin2
hideTurtle
PenUp
; setsc 4
setpc BitPixel coin1 32 56
setfc "white
enableTexture
enableCylinderLines
disableRoundLineEnds
setPenSize [176 176]
setUpdateGraph false
perspective
cs
phi=0
y=200
vy=-1
ay=0.4
R=100
miny=-300
alpha=random 360
deltaAlpha=10
escape=false
setLightAmbient "gold
until [escape]
[ clearScreen
setfc "white
; setpc rgb 0 0 0 sety miny pd setx -200 setx 200 pu
; home
sety y
; right alpha
; pd fd 100 back 200 pu
;comment
;[
down alpha
; rightRoll 3
; right phi
Texture coin1tex
fillRect [-100 -100][100 100]
rr 180 up 90
disableTexture
pd fd 12 pu
enableTexture
down 90
Texture coin2tex
fillRect [-100 -100][100 100]
down 90 fd 12 up 90 rr 180
; left phi
phi=phi+1
;]
y=y+vy
vy=vy-ay
alpha=alpha+deltaAlpha
if or y-R*(sin mod abs alpha-90 180) < miny
y-R*(sin mod abs (270-alpha) 180) < miny
[ vy=vy+ay
y=y-vy
vy= -0.7*vy
alpha=alpha-deltaAlpha
deltaAlpha= -deltaAlpha
if or (mod abs (alpha-90) 180) < 80
(mod abs (270-alpha) 180) < 80
[ deltaAlpha= deltaAlpha*0.8
]
updateVars
]
if (abs deltaAlpha) < 0.001 [stop]
updateGraph
if KeyP
[ ch=readChar
if ch==char 27 [escape=true]
]
; escape=true
waitms 10
]
;redraw
; rotateScene
end