Modern motion detection video game systems (Wii/Wii U, Xbox Kinect, PS Move, etc.) need sensors to read for motion and user input. However, when you play Duck Hunt (and some other games) on the NES, the light gun has no sensor. How does the game know where you are aiming, and if it doesn't need a sensor to track motion, why do modern game systems need them?
The Zapper worked by receiving light through the photodiode at the front of the gun in the barrel.
mental_floss has a really great description of what happens:
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. In the event of multiple targets, a white block is drawn around each potential target one at a time. The diode’s reception of light combined with the sequence of the drawing of the targets lets the computer know that you hit a target and which one it was. Of course, when you’re playing the game, you don’t notice the blackout and the targets flashing because it all happens in a fraction of a second.
Here's an image from Nintendo's Video target control and sensing circuit for photosensitive gun patent on how the hardware works:
More images on the entire process flow are also available in that patent link.
This is why if you pointed the Zapper at a white light you would automatically hit any target with perfect accuracy, at least in Duck Hunt.
Quality light guns rely upon the fact that television sets not only used to draw the picture top to bottom, left to right, but they did so with timing controlled by the video source. On black and white television sets, the electron beam would switch on and off almost instantly in response to changes in the input video signal; color sets needed to add a little delay for color processing, but depending upon the color encoding used (which varies between PAL, NTSC, SECAM, and other video formats) the delay would either be less than 1/100 of a scan line, very close to one scan line exactly, or very close to two scan lines exactly. A quality light gun which saw a pulse of light could infer that the beam must have just passed the spot upon which the gun was focused; since it knew where the beam was at any moment, that would tell it where the gun was pointed.
A limitation of this approach is that it only works well for parts of the screen that are fairly bright; the light gun won't be able to see parts of the screen that are dark. Games with a light gun must ensure that any portion of the screen for which the gun needs to register a position will be bright enough to be detected. Some games flash the entire screen white for that purpose; I'm not positive whether the NES flashes the ducks (versus the whole screen) because flashing a smaller area is less annoying than flashing a large one, or because it can't sense timing well enough to determine beam position and is simply looking for a bright flash, but some other light guns were capable of sensing where on the screen the gun was pointed.