The Evil Mouse Puddle is designed to be dropped on a bitmap sprite while looping on the frame. It renders DIRECT-TO-STAGE, i.e., you cannot put other sprites on top of it without suffering silly consequences.
-------------------------------------------------------------------------------------------
-- Evil Mouse Puddle Behavior by Scott Southworth, scott@evilfish.org, www.evilfish.org
-- Copyright 2001
-- Feel free to use this behavior with any of your projects, to credit me or not to credit
-- me, to send me stuff you've done with it, to give me work, love and/or appreciation.
-- All I ask is that you leave me in the comments, don't resell this script, etc.
-- Etc = Ripping me off :)
-------------------------------------------------------------------------------------------
-- The Evil Mouse Puddle is designed to be dropped on a bitmap sprite while looping on
-- the frame. It renders DIRECT-TO-STAGE, i.e., you cannot put other sprites on top of
-- it without suffering silly consequences.
-------------------------------------------------------------------------------------------
property my_mem_img -- my member image
property my_overlay_img -- my_overlay_img image buffer
property my_sprite -- my sprite
property my_circlelist -- list of ripples in action
property my_working_img -- my working image
property my_lastloc -- last mouse location
property my_lastcount -- last count of ripples in action
on beginsprite me
my_lastloc = the mouseloc
my_circlelist = []
-- get the references to the background image sprite we are using
my_sprite = sprite(me.spritenum)
this_member = sprite(me.spritenum).member
-- clear the my_overlay_img image buffer
my_overlay_img.fill(my_overlay_img.rect,rgb(0,0,0))
-- loop through ripples in the my_circlelist and determine a minimum refresh area
allrect = my_working_img.rect
cc = my_circlelist.count
if cc > 0 then
now = the ticks
repeat with ii = 1 to cc
-- determine information and current rect of action for each ripple in the circlelist
tt = my_circlelist[ii][4]
rr = (now - my_circlelist[ii][3])
yy = my_circlelist[ii][2]
xx = my_circlelist[ii][1]
vv = (tt * 40 + 50) * (49 - rr) / 60.0
temprect = rect(xx-rr,yy-rr,xx+rr,yy+rr)
if ii = 1 then
allrect = temprect
else
allrect = union(allrect, temprect)
end if
-- draw a ripple onto the my_overlay_img buffer
my_overlay_img.draw(temprect,[#shapeType:#oval, #lineSize:4, #color: rgb(vv,vv,vv)])
end repeat
-- remove ripples more than 50 ticks old
repeat with ii = cc down to 1
if (now - my_circlelist[ii][3] ) > 50.0 then
my_circlelist.deleteAt(ii)
end if
end repeat
end if
-- determine quads for the light and dark ripples (offset by 2 pixels)
q1 = [point(allrect[1],allrect[2]),point(allrect[3], allrect[2]),point(allrect[3], allrect[4]),point(allrect[1], allrect[4])]
q2 = q1.duplicate()
q2[1] = q2[1] - point(2,2)
q2[2] = q2[2] - point(2,2)
q2[3] = q2[3] - point(2,2)
q2[4] = q2[4] - point(2,2)
-- if any ripples existed in the last frame, draw ripples
-- (this will clean up any remnants if there are none left in the current frame)
if my_lastcount > 0 then
-- build the resultant image that we will draw
-- a beveled effect is achieved by using inks 33 and 35 in tandem
my_working_img.copypixels(my_mem_img, q1,aLLrect,[#useFastQuads: TRUE])
my_working_img.copypixels(my_overlay_img,q1,allrect,[#ink: 35, #useFastQuads: TRUE])
my_working_img.copypixels(my_overlay_img,q2,allrect,[#ink: 33, #useFastQuads: TRUE])
-- draw this direct to stage to get the yummy speed boost
(the stage).image.copypixels(my_working_img, allrect + rect(my_sprite.left,my_sprite.top,my_sprite.left,my_sprite.top) ,allrect )
end if
my_lastcount = cc
end
on mousewithin me
-- if the mouse has moved, add a ripple to the my_circlelist
if the mouseloc = my_lastloc then
else
thiscirc = [the mouseh+1 - my_sprite.left, the mousev+1-my_sprite.top, the ticks -5, 0]
my_circlelist.append(thiscirc)
end if
my_lastloc = the mouseloc
end
Contact
MMI
36 South Court Sq
Suite 300
Newnan, GA 30263
USA