Log in

View Full Version : Light guns: Please explain them to me.



Querjek
01-10-2004, 08:42 PM
Most of you out there (hopefully all) know what I mean when I say "light gun". But I have never been able to understand how these devices work. I Know that the TV doesn't have extra "sensors" built in, because that wouldn't make sense. How do these things work? I need a good explanation.

jonjandran
01-10-2004, 08:56 PM
How does the light gun for a video game work?



Lots of home video games and arcade games use some sort of gun as an input device. You point the gun at the screen and pull the trigger, and if you hit the target on the screen, the target explodes.

To create this effect, the gun contains a photodiode (or a phototransistor) in the barrel. The photodiode is able to sense light coming from the screen. The gun also contains a trigger switch. The output of the photodiode and the switch are fed to the computer controlling the game.

At the same time, the computer is getting signals from the screen driver electronics. If you have read How Television Works, you know about the horizontal retrace and vertical retrace signals used to align the picture on the screen. The screen driver electronics send pulses to the computer at the start of the horizontal and vertical retrace signals, so the computer knows where on the screen the electron beam is located during each frame.

The computer normally uses one of two different techniques to figure out whether or not the gun is pointed at the target when the user pulls the trigger:

* The computer blanks the screen and then paints just the target object white. If the photodiode senses darkness after one vertical retrace signal and then light after the next, the computer assumes that the gun is pointed at the target and scores a hit.

* The computer blanks the screen and then paints the entire screen white. It takes time for the electron beam to trace the entire screen while painting it white. By comparing the signal coming from the photodiode with the horizontal and vertical retrace signals, the computer can detect where the electron beam is on the screen when the photodiode first senses its light. The computer counts the number of microseconds that pass between the time the horizontal and vertical retrace signals start and the time the photodiode first senses light. The number of microseconds tells the computer exactly where on the screen the gun is pointing. If the calculated position and the position of the target match, the computer scores a hit.

Querjek
01-10-2004, 09:00 PM
Hmm. I understood most of that. Did you just type that up? It sounds like it came from a book or something. So, then, if I was to take the plastic piece off of the end of my NES lightgun, would the entire screen be "shot"?

jonjandran
01-10-2004, 09:16 PM
Hmm. I understood most of that. Did you just type that up? It sounds like it came from a book or something. So, then, if I was to take the plastic piece off of the end of my NES lightgun, would the entire screen be "shot"?

Copied it off a website. :embarrassed:

I think ithe plastic piece on the end of the lightgun is used to focus the light onto the photodiode.

So if you took it off it wouldn't focus the light right and would probably cause the gun to either "hit" the target every time or "miss" it every time.

Pantechnicon
01-10-2004, 10:29 PM
How does the light gun for a video game work?



Lots of home video games and arcade games use some sort of gun as an input device. You point the gun at the screen and pull the trigger, and if you hit the target on the screen, the target explodes.

To create this effect, the gun contains a photodiode (or a phototransistor) in the barrel. The photodiode is able to sense light coming from the screen. The gun also contains a trigger switch. The output of the photodiode and the switch are fed to the computer controlling the game.

At the same time, the computer is getting signals from the screen driver electronics. If you have read How Television Works, you know about the horizontal retrace and vertical retrace signals used to align the picture on the screen. The screen driver electronics send pulses to the computer at the start of the horizontal and vertical retrace signals, so the computer knows where on the screen the electron beam is located during each frame.

The computer normally uses one of two different techniques to figure out whether or not the gun is pointed at the target when the user pulls the trigger:

* The computer blanks the screen and then paints just the target object white. If the photodiode senses darkness after one vertical retrace signal and then light after the next, the computer assumes that the gun is pointed at the target and scores a hit.

* The computer blanks the screen and then paints the entire screen white. It takes time for the electron beam to trace the entire screen while painting it white. By comparing the signal coming from the photodiode with the horizontal and vertical retrace signals, the computer can detect where the electron beam is on the screen when the photodiode first senses its light. The computer counts the number of microseconds that pass between the time the horizontal and vertical retrace signals start and the time the photodiode first senses light. The number of microseconds tells the computer exactly where on the screen the gun is pointing. If the calculated position and the position of the target match, the computer scores a hit.

Did you get this info from The Straight Dope (http://www.straightdope.com)? I seem to recall Cecil doing a column on this recently but I couldn't find it on the website. I was going to link it, alas...

jonjandran
01-10-2004, 10:32 PM
www.howstuffworks.com/static/question273.htm

That's where I got it from.

wufners
02-17-2004, 05:42 PM
By the way,

For all you crazy kids who like knowing stuff, www.howstuffworks.com is one of the best sites this great internet of our has to offer. Use your knowledge wisely.