/***************
 * NAME:        coin.ray
 * DESCRIPTION: Jumping coin animation with motion blur
 * AUTHOR:      Andreas Heumann
 ***************/

signal on error

options results

IF ~show('P','RAYSTORM') THEN DO
	address COMMAND 'run >NIL: <NIL: /RayStorm'
	address COMMAND WaitForPort RAYSTORM
END  

address RAYSTORM

'OBJECTPATH /objects'

'SETSCREEN 160 128'
'SETCAMERA <0,4,9> <0,3.5,0> <0,1,0> 68.75 55'
'SETWORLD [0,0,100]'
'POINTLIGHT <0,4,9> SHADOW'

'NEWACTOR COIN <3,0.1,0>'

frames = 30
vy = .8
y = 1
do i=0 to frames
	'POSITION 'i' 'i+1' <'3-((i+1)/(frames/6))','y',0>'
	y = y + vy
	vy = vy - (1.724/frames)
	'ALIGNMENT 'i i+1' <0,0,24*(i+1)>'
end

'LOADOBJ coin.iob <3,0,0> <0,0,0> <1,1,1> ACTOR=COIN'

'DISTRIB 3'

do i=0 to frames
	'STARTRENDER QUICK FROM 'i' TO 'i+1
	'SAVEPIC coin' || RIGHT(i+1,4,0) || '.iff'
end

'CLEANUP'

exit 0

error:
say "Error" rc "in line" sigl ":"
GETERRORSTR rc
say result
exit 0
