When you point at a duck and pull the trigger, the computer in the NES blacks out the screen and the Zapper diode begins reception. Then, the computer flashes a solid white block around the targets you’re supposed to be shooting at. The photodiode in the Zapper detects the change in light intensity and tells the computer that it’s pointed at a lit target block — in others words, you should get a point because you hit a target.
I must say: that Nintendo gun was one of the coolest things you could have when I was a kid — the only thing that would be cooler was the Nintendo Power Glove (you know what I’m talking about).1
It is a pretty impressive solution they came up with for the gun.