The Duck Hunt gun primarily just consists of a button (the trigger) and a photodiode (light sensor). When you pull the trigger, this causes the sport to form the TV screen go utterly black for one frame. At this point, the game uses the light sensor to sample the black color it’s reading from your TV to give it a reference point for the given ambient light at the time.
In the next frame, the game causes the target area to turn white, with the rest remaining black. If the sport detects a shift from black to white from the gun’s photodiode therein jiffy, it knows you were aiming correctly at the target and so doesn’t specifically have to be compelled to recognize something regarding wherever on the screen the target is. For games with multiple targets at any given time, the same type of method is used except multiple target frames are shown. So the game will flash the black reference screen; then will flash one of the targets, leaving the rest of the screen black; then flashes the next target, again leaving the rest of the screen black; and so on. The game knows which target is hit, if any, by which frame is currently being shown when a light shift is detected.
Interestingly, if you read over the patent for the NES Zapper Gun, one of the main features they point out which separates their gun from previously patented light detecting guns is that in the “preferred embodiment” of their system, it has the ability to distinguish between multiple targets in one frame. However, that’s not actually what they did in the NES system as noted. In contrast, in a “one frame” system, it uses a signal from the TV itself. This signal is in the form of pulses which signify the start of the horizontal and vertical retracing.
The computer connected to the TV will use these pulses to additional or less tell what space is presently being copied on the TV; it will then time
this with a shift in light detected by the photodiode. Thus, with precise enough temporal arrangement, it’s able to notice that target is being hit in mere one frame.
With this method, the flash can happen fast enough that it’s nearly imperceptible to most people, unlike in the actual NES system where when multiple targets are shown, most people can perceive the flash. The NES system did use the vertical retrace signal to be able to detect the start of each frame though, but didn’t use it to detect anything about the position of the target as in the “preferred embodiment” described in the patent.