Here's a script I made for Duck Hunt. It draws a red box around the duck if you play the "1 duck" game, and if you play the "2 duck" game it will draw a blue box around the duck number 2.
The code might be ugly and all, but at least it works. :) It's not modified to work for clay shooting yet.
while true do
local function displayer()
duck1x = memory.readbyte(0x303)
duck1y = memory.readbyte(0x302)
duck2x = memory.readbyte(0x353)
duck2y = memory.readbyte(0x352)
box1xcenter = duck1x
box1ycenter = duck1y
box2xcenter = duck2x
box2ycenter = duck2y
boxwidth = 32
boxheight = 32
xoffset = 0
yoffset = 8
--Sets the coordinates for the sides of the boxes.
leftside1 = box1xcenter-boxwidth/2 +xoffset
bottomside1 = box1ycenter+boxheight/2 -yoffset
rightside1 = box1xcenter+boxwidth/2 +xoffset
topside1 = box1ycenter-boxheight/2 -yoffset
leftside2 = box2xcenter-boxwidth/2 +xoffset
bottomside2 = box2ycenter+boxheight/2 -yoffset
rightside2 = box2xcenter+boxwidth/2 +xoffset
topside2 = box2ycenter-boxheight/2 -yoffset
--The following if-operations force the boxes to stay on screen, thus avoiding error messages.
if bottomside1>223 then bottomside1 = 223 end
if bottomside1<0 then bottomside1 = 0 end
if topside1 <0 then topside1 = 0 end
if rightside1 >255 then rightside1 = 255 end
if leftside1 <0 then leftside1 = 0 end
if bottomside2>223 then bottomside2 = 223 end
if bottomside2<0 then bottomside2 = 0 end
if topside2 <0 then topside2 = 0 end
if rightside2 >255 then rightside2 = 255 end
if leftside2 <0 then leftside2 = 0 end
--Now it's time to draw the boxes!
if duck1x>0 and duck1y>0 then gui.drawbox(leftside1,bottomside1,rightside1,topside1, "red") end
if duck2x>0 and duck2y>0 then gui.drawbox(leftside2,bottomside2,rightside2,topside2, "blue") end
end
gui.register(displayer)
FCEU.frameadvance()
end