Main Restorations Software Audio/Jukebox/MP3 Everything Else Buy/Sell/Trade
Project Announcements Monitor/Video GroovyMAME Merit/JVL Touchscreen Meet Up Retail Vendors
Driving & Racing Woodworking Software Support Forums Consoles Project Arcade Reviews
Automated Projects Artwork Frontend Support Forums Pinball Forum Discussion Old Boards
Raspberry Pi & Dev Board controls.dat Linux Miscellaneous Arcade Wiki Discussion Old Archives
Lightguns Arcade1Up Try the site in https mode Site News

Unread posts | New Replies | Recent posts | Rules | Chatroom | Wiki | File Repository | RSS | Submit news

  

Author Topic: Lightgun Game  (Read 4226 times)

0 Members and 1 Guest are viewing this topic.

Quacker Blaster

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 10
  • Last login:October 31, 2013, 06:41:39 pm
  • Quacker Blaster Lead Developer!
    • Quacker Blaster
Lightgun Game
« on: February 06, 2013, 06:30:33 pm »
I am in the works of creating a pc-based lightgun arcade game and am interested in knowing how arcade games detected where the player fired the gun. If someone could post or link to source code in C++ that i can implement into my game, it would be greatly appreciated.

Sincerely,

Quacker Blaster

Howard_Casto

  • Idiot Police
  • Trade Count: (+1)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 19427
  • Last login:Today at 02:45:49 am
  • Your Post's Soul is MINE!!! .......Again??
    • The Dragon King
Re: Lightgun Game
« Reply #1 on: February 06, 2013, 11:10:09 pm »
How arcade games detected the lightgun would be irrelevant for your project.  All pc-based lightguns show up as either a mouse, or a joystick.  That makes for easy interfacing. 


The short of it is arcade lightgun games used a light sensor, a trigger and the natural timing of the monitor and the fact that crt screens draw from left to right, top to bottom, one pixel at a time.  When the trigger is pulled, the game would draw the screen white.  Since it turns white one pixel at a time (extremely rapidly) it timed how long it took from when the trigger was pulled until the light sensor detects white to figure out the x and y position on the monitor.  You aren't going to be able to do this on a lcd.  Eveen if you wanted to do it for a crt-based right the timing is so critical that you need a hard-ware based solution to keep track of it.... so yeah... just use pc guns. 

Quacker Blaster

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 10
  • Last login:October 31, 2013, 06:41:39 pm
  • Quacker Blaster Lead Developer!
    • Quacker Blaster
Re: Lightgun Game
« Reply #2 on: February 06, 2013, 11:18:41 pm »
How arcade games detected the lightgun would be irrelevant for your project.  All pc-based lightguns show up as either a mouse, or a joystick.  That makes for easy interfacing. 


The short of it is arcade lightgun games used a light sensor, a trigger and the natural timing of the monitor and the fact that crt screens draw from left to right, top to bottom, one pixel at a time.  When the trigger is pulled, the game would draw the screen white.  Since it turns white one pixel at a time (extremely rapidly) it timed how long it took from when the trigger was pulled until the light sensor detects white to figure out the x and y position on the monitor.  You aren't going to be able to do this on a lcd.  Eveen if you wanted to do it for a crt-based right the timing is so critical that you need a hard-ware based solution to keep track of it.... so yeah... just use pc guns.
Thanks for the explanation and suggestion. Can you recommend any cheap PC-based light guns for me to try? All i could find while googling was this which is pretty expensive if all you want to do testing. Is this what it normally costs for a PC-based lightgun or can i find something better?

Sincerely,

Quacker Blaster

Howard_Casto

  • Idiot Police
  • Trade Count: (+1)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 19427
  • Last login:Today at 02:45:49 am
  • Your Post's Soul is MINE!!! .......Again??
    • The Dragon King
Re: Lightgun Game
« Reply #3 on: February 07, 2013, 01:50:33 am »
Your link is invalid. 

A pc lightgun is going to cost around 50 to 100 bucks. 

There are cheaper alternatives, but be prepared for headaches..... guns made for the wii are rather cheap but we still have interface issues with them. 

BadMouth

  • Trade Count: (+6)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 9270
  • Last login:July 14, 2025, 01:30:54 pm
  • ...
Re: Lightgun Game
« Reply #4 on: February 07, 2013, 09:05:26 am »
Real light guns aren't made anymore due to the decline in CRTs.  :'(

The most popular IR guns are:

Aim-Trak http://www.ultimarc.com/JShopServer/section.php?xSec=7&xPage=1&jssCart=c5b9c013c87d0c84ea03b1d6dfbdd498
               For testing, you can just buy the electronics.  You'll need a couple switches to attach.
               The same guts are also sold with different shells at www.arcadeguns.com
               This is the most hassle free of current options.

EMS Top Gun 3: http://www.amazon.com/EMS-Wireless-Display-Including-Projectors/dp/B0073X8MR0/ref=sr_1_1?ie=UTF8&qid=1360245540&sr=8-1&keywords=pc+light+gun

Like Howard said, wii controllers can be made to work (search this forum for wii glovepie scripts), but pairing them can be a PITA and I actually get the blue screen of death half the time when I try to pair a second one.

What sucks about light gun game nowadays is that the IR guns aren't accurate enough to use the sights on the gun, so you must have on-screen crosshairs (like a wii game).  The old CRT guns were accurate down to a pixel.

Howard_Casto

  • Idiot Police
  • Trade Count: (+1)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 19427
  • Last login:Today at 02:45:49 am
  • Your Post's Soul is MINE!!! .......Again??
    • The Dragon King
Re: Lightgun Game
« Reply #5 on: February 07, 2013, 05:24:42 pm »
Yeah I didn't mean a literal lightgun, those just aren't used anymore.  For the lamen though they are the "same thing". 

Xiaou2

  • Trade Count: (+1)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 4134
  • Last login:June 11, 2025, 11:55:17 pm
  • NOM NOM NOM
Re: Lightgun Game
« Reply #6 on: February 07, 2013, 07:47:47 pm »
Actually, I bet it would be possible to simulate a CRT based response on an LCD.

 You would just need to add a counter, which would keep track of where on the virtual CRT the
pixels are being drawn.  Once you click the trigger, you would have a flash response occur,
and by combining the data, should be able to figure out the positioning.

Howard_Casto

  • Idiot Police
  • Trade Count: (+1)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 19427
  • Last login:Today at 02:45:49 am
  • Your Post's Soul is MINE!!! .......Again??
    • The Dragon King
Re: Lightgun Game
« Reply #7 on: February 07, 2013, 09:48:17 pm »
If there was  a way, I'm sure the modern arcades would be doing it.  Sega still releases shooters to the arcade regularly and they have completely switched over to IR guns so they can offer different monitor options. Their rigs cost a small fortune, so I doubt they'd skimp. 

SithMaster

  • Lets see how happy you are when you need to use a lawn mower and it keeps turning off when you want to cut up zombies.
  • Trade Count: (+4)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 1781
  • Last login:January 12, 2014, 03:52:59 pm
  • The brightest light casts the darkest shadow.
Re: Lightgun Game
« Reply #8 on: February 08, 2013, 01:17:09 am »
I can't remember if this was mentioned in the previous discussions on the aimtrak and the wiimote but wouldn't four leds (one in each corner of the monitor) provide the best performance aside from being slightly off depending on whether they are placed on the screen or the bezel?  If you don't need Silent Scope accuracy then it should be fine for time crisis type games and can be prototyped with two wii sensor bars slightly modified perhaps assuming there is any merit in this theory.
Back in MY day we lived on the moon and we had to build a rocket ship from scratch to get to the Earth before we suffocated.

Howard_Casto

  • Idiot Police
  • Trade Count: (+1)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 19427
  • Last login:Today at 02:45:49 am
  • Your Post's Soul is MINE!!! .......Again??
    • The Dragon King
Re: Lightgun Game
« Reply #9 on: February 08, 2013, 02:27:17 am »
That's how sega does it from what I can remember.  They have ir arrays all around the bezel, not just at the top.    Honestly my wiimote scripts, if you stand far enough away and recalibrate before you start are pretty darn accurate.  Maybe not pixel perfect, but I managed to play a game of duckhunt with the crosshairs turned off, so that's about as good as you need it imho. 


There are other reasons the industry switched over to ir guns as well.  No flickering screen, constant tracking, ect.  Except for a dip in accuracy, they are superior in every other way.

Xiaou2

  • Trade Count: (+1)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 4134
  • Last login:June 11, 2025, 11:55:17 pm
  • NOM NOM NOM
Re: Lightgun Game
« Reply #10 on: February 08, 2013, 10:32:31 am »
If there was  a way, I'm sure the modern arcades would be doing it.  Sega still releases shooters to the arcade regularly and they have completely switched over to IR guns so they can offer different monitor options. Their rigs cost a small fortune, so I doubt they'd skimp.

 Thats not true, nor is it good logic.

 One of the reasons why, may in fact be that the needed white flash, is the real issue.  And or the fact that nobody really put a lot of thought and effort into it.  Which in such a fast paced corporate red-tape business.. is pretty much standard operation.

 If you want to test pixel accuracy, then do just that.  Make a set of static targets all over the screen, that are pixels, or small bulls-eyes.  When the gun is fired, have it draw a different colored pixel where it landed.  Have another test, where you try to fire in the exact same spot for 20 shots.   Have it cycle the colors, so you can tell where each shot landed.

 Furthermore, Duckhunt isnt a test. Try Shooting Gallery for the Sega Master System.  A few superior game, requiring far superior accuracy.

Howard_Casto

  • Idiot Police
  • Trade Count: (+1)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 19427
  • Last login:Today at 02:45:49 am
  • Your Post's Soul is MINE!!! .......Again??
    • The Dragon King
Re: Lightgun Game
« Reply #11 on: February 08, 2013, 04:45:36 pm »
ugh man, that was my nice answer because I knew you would start. 

Technical answer:

1.  Lcds don't draw the screen one pixel at a time, they have buffers. At their slowest they draw a single line at a time.  So no x-tracking.  There's also this wierd method of interlaced redraw that's used on some lcds.  (Not true interlacing... but rather first the odd pixels are re-drawn for the next frame, then the even, to speed up the refresh rate.)

2.  Lcds don't have a standard refresh rate like crts did.  So you'd have to build a gun for 60hz, 100 and 120hz.  That's not a huge issue, but it means your gun needs three chips or a varible timing chip, which adds to the expense.     

3.  A lcd monitor doesn't give off enough incandescent light to trip a light sensor.  Yes they could use a more powerful sensor, but it'd have to be so powerful to detect the white on a lcd that it'd often be thrown off by light around the room. 

Upon working on this solution they tried a camera, same issues in regards to sensitivity.  Then somebody had the bright idea to put a ir filter on the camera and put tracking dots around the screen.  The ir-gun ws born.   

I'm sure shooting gallery has smaller targets, but seeing as how nobody cares about that game I don't see how it would matter.  Most people want to play the modern lightgun games (area 51, virtua cop, ect) and the targets on those games are huge and don't move around a lot.  The ducks in duckhunt are tiny and irratic by comparison. 


As soon as crts went by the way-side I did extensive research on this and continue to do so. I've even been actively working with the community to find solutions.  Trust me, a true lightgun or any mutation of one is not the solution.  Could you please be nice this time and just let this one go?

Xiaou2

  • Trade Count: (+1)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 4134
  • Last login:June 11, 2025, 11:55:17 pm
  • NOM NOM NOM
Re: Lightgun Game
« Reply #12 on: February 08, 2013, 11:46:18 pm »
Quote
1.  Lcds don't draw the screen one pixel at a time, they have buffers. At their slowest they draw a single line at a time.  So no x-tracking.  There's also this wierd method of interlaced redraw that's used on some lcds.  (Not true interlacing... but rather first the odd pixels are re-drawn for the next frame, then the even, to speed up the refresh rate.)

 - Which is why I suggested a combintation of a virtual timer and other methods, to determine position.  A sort of virtual CRT simulation.  Once calibrated.. does not the drawing timing (freq) stay constant for a typical CRT?  Is it not possible to time virtual electron drawing (without actually drawing) to a certain sized LCD?


Quote
2.  Lcds don't have a standard refresh rate like crts did.  So you'd have to build a gun for 60hz, 100 and 120hz.  That's not a huge issue, but it means your gun needs three chips or a varible timing chip, which adds to the expense.

 So what.  Costs of such things is probably under a dollar.  Even if it costs 20$, people would pay for the accuracy.  A gun with crappy accuracy, isnt worth anything to me, Which is why I, and many others, keep our console systems.

 But as said, this isnt to do with Hz.  This is something that could be done programatically.. I think.  Which could mean that anything that uses it, would have to use a certain programmed tracking to utilize it.


Quote
Upon working on this solution they tried a camera, same issues in regards to sensitivity.  Then somebody had the bright idea to put a ir filter on the camera and put tracking dots around the screen.  The ir-gun ws born.


  According to wiki, one of the methods involves a camera, and flashing a certain pattern of dots in that position of the place where the electron gun was to be.  An interesting idea.  There are other systems they mention as well.

Quote
I'm sure shooting gallery has smaller targets, but seeing as how nobody cares about that game I don't see how it would matter.  Most people want to play the modern lightgun games (area 51, virtua cop, ect) and the targets on those games are huge and don't move around a lot.  The ducks in duckhunt are tiny and irratic by comparison.

 May I point out to you, 'Point Blank', which has several sequels in the series. (as well as time crisis)  While yes, there are a lot of larger targets in these games.. there are times when you have to avoid shooting a target thats in front of another. (or a target just barely behind something else, as in timecrisis.. and yeah, PB targets move all over the place)   

 I believe there are high accuracy shots in PB too.   In fact, I believe Shooting Gallery is the precursor, and inspiration, for Point Blank.  It uses the same kind of level challenge system.  However, the levels are longer in SG, and the game just feels much better as a result.  PB is a little too 'ADD' for me... though, it does have some cool and fun levels.  SG could have easily been a top earner arcade machine.  Its probably the best, most fun, and most challenging lightgun game, that Ive ever played, hands down.


Quote
As soon as crts went by the way-side I did extensive research on this and continue to do so. I've even been actively working with the community to find solutions.  Trust me, a true lightgun or any mutation of one is not the solution.  Could you please be nice this time and just let this one go?

 So what your saying, is that because you cant seem to figure it out.. that nobody else could?  And that me bringing up my opinion, is 'starting'.. as if Im trying to pick some sort of fight?  On the Outrun board, you even went so far as to say I was angry... and yet, I had no anger, nor used anger in my replies.  Its you who is putting a negative spin on things, not me.   And I have a right to an opinion... even if you do not agree with it.

Quacker Blaster

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 10
  • Last login:October 31, 2013, 06:41:39 pm
  • Quacker Blaster Lead Developer!
    • Quacker Blaster
Re: Lightgun Game
« Reply #13 on: February 18, 2013, 08:02:16 pm »
Guys stop fighting! Question for the EMS Top Gun 3, there are a couple of reviews where the gun doesn't function properly(1/2 star reviews) or the batteries overheat and melt the battery cover(2 star review). Has anyone experienced this problem and if so would you still reccommend i get it? I added mouse support to my game based on:
Quote
All pc-based lightguns show up as either a mouse, or a joystick.  That makes for easy interfacing.
Seeing as i can't afford a lightgun right now, should i just declare light gun support untested?
Any assistance in this matter would be greatly appreciated.

Sincerely,

Quacker Blaster

Aceisback

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 53
  • Last login:February 04, 2021, 07:45:41 pm
  • I want to build my own arcade controls!
Re: Lightgun Game
« Reply #14 on: February 23, 2013, 09:43:00 pm »
I am using an EMS III gun.

Once I got the unsigned driver issue figured out (For Windows 7 64bit), and Ramjet's border fix installed for the model 2 emulator, it has been working great. I wouldn't say it is perfect, but it is working well for me right now. I may try a better gun later, but I am happy with the EMS right now. The only thing I really don't like about it is that it is difficult to press the buttons to disable the recoil correctly (for me anyway).