Sign in to follow this  
invictus

Programming against those good old laser gun input devices

Recommended Posts

invictus    122
Hi I was wondering if anyone has any information about how to program against those good old laser gun input devices we know from consoles and computers? I really would like to try it out sometime. Thanks in advance :)

Share this post


Link to post
Share on other sites
Adam Hamilton    271
I was thinking of designing a light gun a while ago. The problem I faced was that I needed to know which scanline the CRT is tracing. I think there is a function in DirectX that tells you the current scan line but it may be device dependent.

If you have an TFT LCD monitor then forget about using a light gun.

I think they work by starting a ramp generator everytime a new scanline is traced out and when you press that trigger button**, the scanline count (The gun keeps track of this with an internal counter that is refreshed on the vertical blanking pulse) and the analog value of the ramp which is then converted to a digital code and this is passed to the computer as an x,y pair.

** There is a little magnifying glass before the photodiode sensor (You can see this if you stare down the barrel of a light gun) This is to magnify the screen so much so that all that photodiode sees is 1 pixel

I am not sure if this is how they really do it but this seems most logical. (And it is they way I would do it)

Maybe someone out there can either confirm it or know of how they do it. :)

Share this post


Link to post
Share on other sites
Funkymunky    1413
it depends on the light gun type, doesn't it? The old nintendo one had that thing you put on the tv that measured the x and y offset...but i remember seeing one fairly recently for the ps2 that just plugged in as a controller and was useable without one of those x-y things (although it had terrible accuracy)

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
Nah, the old nintendo one doesn't need anything extra, just plug it in and you're off playing duck hunt.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
Or maybe you are talking about the SNES gun.

Share this post


Link to post
Share on other sites
Haytil    525
The old NES light-gun was only used for duck hunt, I think.

The way it worked was as follows:

Whenever the trigger was pulled, a white square was briefly, for one frame, flashed at the duck's current position, while the rest of the screen was black. This was quick enough that the user only noticed a "flash," as if his gun had fired in reality.

Then the lightgun simply checked to see if it was seeing white or black. If it saw white, it triggered a "hit." If not, it was a miss.

You could fool around and cheat by using a flashlight to simulate the square, triggering a "hit" every time.

Edit: The following wikipedia article has perhaps a better explanation: http://en.wikipedia.org/wiki/NES_Zapper

Share this post


Link to post
Share on other sites
Adam Hamilton    271

The link below describes a couple of methods. I was almost right as method 2 explains :)

This probably explains why you also had to plug those GCON light guns for the PS2 into the video in port on your TV/VCR

http://en.wikipedia.org/wiki/Light_gun

Share this post


Link to post
Share on other sites
helix    301
I had never understood how that thing worked. I learned something new. :)

As I recall, there were more games than just Duck Hunt that used it. Weren't there some where you shot gophers and other things like that?

Share this post


Link to post
Share on other sites
Xelen    312
Quote:
Original post by helix
I had never understood how that thing worked. I learned something new. :)

As I recall, there were more games than just Duck Hunt that used it. Weren't there some where you shot gophers and other things like that?


Yes, by looking at the Wikipedia there is apparently more games than I thought would be supported by the gun.


Quote:
Quote from Wikipedia Article

Games



The Adventures of Bayou Billy
Baby Boomer
Barker Bill's Trick Shooting
Chiller
Duck Hunt
Freedom Force
Gotcha!
Gumshoe
Hogan's Alley
Laser Invasion
The Lone Ranger
Mechanized Attack
Operation Wolf
Shooting Range
To the Earth
Track & Field II
Wild Gunman



Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
There is another version of lightguns, that emit infrared light. The gun is a simple infrared emitter like a remote control, and the target area has 3 or more sensors that get different amount of light based on the direction of the gun. This allows the simple triangulation of the positon based on the different analog levels received by the sensors. When every sensor gets equal values the emitter is pointing at the center of the target area. This technology was used in elder east european made arcades, children's toys and some low budget military training systems. (you only needed to fit the emitter on a real gun and use a target board with sensors in the corners) One feature of this system is that it produces analog output from the sensor decoder so it could also be used with analog joystic ports. I would note that the technology does not depend on any screen types so it can be used for today's games too.

Viktor

Share this post


Link to post
Share on other sites
jdarling    232
Well if you want to take the time:
http://www.geocities.com/mellott124/VRGunspec.htm
http://www.geocities.com/mellott124/VrZ.htm
http://www.coinopexpress.com/products/parts/shooting_parts/

There is a good starting point for Lightgun implementations and information. Other then that it comes down to a few things; If you can setup your game to work with a mouse (fire button = mouse button) then you can hack a gyro mouse (or other 3D mouse) to work with the system easily enough. You can also use a gyro module with something like an AVR or PIC (ICK!) if you want to build your own. Personally I'd use one of the USB AVR's and a gyro module (or beacon system).

- Jeremy

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this