/* An Arexx script for use with AmiSlate:  

	Draws explosions emanating from the mouse whenever the mouse
	is clicked
	
   
*/
AMessage.QUIT        = 32	/* AmiSlate is shutting down */


parse arg CommandPort ActiveString

address (CommandPort)

if (length(CommandPort) == 0) then do
	say ""
	say "Usage:  rx explode.rexx <REXXPORTNAME>"
	say "        (REXXPORTNAME is usually AMISLATE)"
	say ""
	say "Or run from the Rexx menu within AmiSlate."
	say ""
	exit 0
	end


options results

GetWindowAttrs stem win.

MaxX = (win.width - 59)
MaxY = (win.height - 54)

range = 35
halfrange = trunc(range/2)

NumberOfLines = 30

do while (1)
	waitevent stem event. MOUSEDOWN MOUSEUP QUIT
	
	if (event.type == AMessage.QUIT) then exit
	
	nL = NumberOfLines
	mx = event.x
	my = event.y
	
	do while (nL > 0)	
		xx = mx + rand(range) - halfrange
		yy = my + rand(range) - halfrange
		line mx my xx yy
		setfcolor rand(15) rand(15) rand(15) notbackground
		nL = nL - 1
		end
end

rand:
	return trunc(Random()*arg(1)/1000)