I late on this one but I did that exact same thing in my unfinished atom mash game
heres the function, it uses global type data but it can easily be edited to be generic, it will create the effect from startAtomID to endAtomID, or to the mouse if no endAtomID found, it scales the lightning effect to suit the distance and sets the correct angle, and yeah, I used offsets lol
Function GUI_Game_DrawMergeOverlay(mouse_x#, mouse_y#, startAtomID, endAtomID)
if GetSpriteExists(startAtomID)
// highlight the start sprite
start_x#=GetSpriteXByOffset(startAtomID)
start_y#=GetSpriteYByOffset(startAtomID)
SetSpritePositionByOffset(gGUIGame.spr_highlight_start, start_x#, start_y#)
SetSpriteVisible(gGUIGame.spr_highlight_start, 1)
SetSpriteColor(gGUIGame.spr_highlight_start, 255, 255, 255, 175)
SetSpriteColor(gGUIGame.spr_highlight_end, 255, 255, 255, 175)
SetSpriteColor(gGUIGame.spr_highlight_line, 255, 255, 255, 175)
// check for an end sprite
if GetSpriteExists(endAtomID)
end_x#=GetSpriteXByOffset(endAtomID)
end_y#=GetSpriteYByOffset(endAtomID)
mid_x#=start_x#+(end_x#-start_x#)/2
mid_y#=start_y#+(end_y#-start_y#)/2
line_distance# = Distance2D(start_x#, start_y#, mid_x#, mid_y#)
line_angle# = ATanFull(start_x#-mid_x#, start_y#-mid_y#)
SetSpritePositionByOffset(gGUIGame.spr_highlight_line, start_x#, start_y#)
SetSpriteAngle(gGUIGame.spr_highlight_line, line_angle#)
SetSpriteSize(gGUIGame.spr_highlight_line, 32, line_distance#*2)
SetSpriteVisible(gGUIGame.spr_highlight_line, 1)
SetSpritePositionByOffset(gGUIGame.spr_highlight_end, end_x#, end_y#)
SetSpriteVisible(gGUIGame.spr_highlight_end, 1)
Start_Atom_Type = GetSpriteGroup(startAtomID)
End_Atom_Type = GetSpriteGroup(endAtomID)
Select Collision_GetMergeStatus(Start_Atom_Type, End_Atom_Type)
Case EVT_GOOD
SetSpriteColor(gGUIGame.spr_highlight_start, 0, 255, 0, 175)
SetSpriteColor(gGUIGame.spr_highlight_end, 0, 255, 0, 175)
SetSpriteColor(gGUIGame.spr_highlight_line, 0, 255, 0, 175)
EndCase
Case EVT_UNKNOWN
SetSpriteColor(gGUIGame.spr_highlight_start, 0, 0, 255, 175)
SetSpriteColor(gGUIGame.spr_highlight_end, 0, 0, 255, 175)
SetSpriteColor(gGUIGame.spr_highlight_line, 0, 0, 255, 175)
EndCase
Case EVT_BAD
SetSpriteColor(gGUIGame.spr_highlight_start, 255, 0, 0, 175)
SetSpriteColor(gGUIGame.spr_highlight_end, 255, 0, 0, 175)
SetSpriteColor(gGUIGame.spr_highlight_line, 255, 0, 0, 175)
EndCase
EndSelect
else
// no end sprite, draw to the mouse
mid_x#=mouse_x#+(start_x#-mouse_x#)/2
mid_y#=mouse_y#+(start_y#-mouse_y#)/2
line_distance# = Distance2D(start_x#, start_y#, mid_x#, mid_y#)
line_angle# = ATanFull(start_x#-mid_x#, start_y#-mid_y#)
SetSpritePositionByOffset(gGUIGame.spr_highlight_line, start_x#, start_y#)
SetSpriteAngle(gGUIGame.spr_highlight_line, line_angle#)
SetSpriteSize(gGUIGame.spr_highlight_line, 32, line_distance#*2)
SetSpriteVisible(gGUIGame.spr_highlight_line, 1)
SetSpritePositionByOffset(gGUIGame.spr_highlight_end, mouse_x#, mouse_y#)
SetSpriteVisible(gGUIGame.spr_highlight_start, 1)
SetSpriteVisible(gGUIGame.spr_highlight_end, 0)
SetSpriteVisible(gGUIGame.spr_highlight_line, 1)
SetSpriteColor(gGUIGame.spr_highlight_start, 255, 255, 0, 175)
SetSpriteColor(gGUIGame.spr_highlight_end, 255, 255, 0, 175)
SetSpriteColor(gGUIGame.spr_highlight_line, 255, 255, 0, 175)
endif
else
SetSpriteVisible(gGUIGame.spr_highlight_line, 0)
SetSpriteVisible(gGUIGame.spr_highlight_end, 0)
SetSpriteVisible(gGUIGame.spr_highlight_start, 0)
endif
EndFunction