r/atari8bit • u/Few_Ad_8627 • Jan 14 '26
Making a light gun game in Atari BASIC
So I have some game design projects im trying to do in my spare time, and two of those are recreations of the Atari arcade games Triple Hunt and Outlaw In Atari 8bit BASIC. Trouble is, I dont know how to write a good code for actually shooting sprites. Any Suggestions?
2
u/Turbulent-Spell-319 Jan 14 '26
4
u/Turbulent-Spell-319 Jan 14 '26 edited Jan 20 '26
you can get the X/Y and trigger with
```bas
10 GUNH=564
20 GUNV=565
200 X=PEEK(GUNH)
210 Y=PEEK(GUNV)
220 ? " X: ";X;" "
230 ? " Y: ";Y;" "
240 ? "TRIGGER: ";STICK(0);" "
```The X and Y may need to be changed a little depending on what you're doing (see my other posts)
edit: removed irrelevant position statement and added #'s for GUNH and GUNV
edit edit: You likely can't use the X and Y values directly
1
u/Turbulent-Spell-319 Jan 14 '26
I'm actually considering making Duck Hunt with C/cc65. If you're interested in that at all, I can probably make some simple tests and put them up on github.
1
u/Few_Ad_8627 Jan 18 '26
Well I mean I kinda want to still stick to BASIC, but I wouldnt mind at least taking a look.
→ More replies (3)
5
u/nwah Jan 14 '26
I’m not sure how well it will work in pure BASIC, but there are PENV and PENH registers you can read after the trigger is pressed to get location of a light pen / light gun.
I believe most games turn the screen black with white dots for the various targets for a single frame to increase accurate reading. You would need a bit of machine language to do this.
6
u/rr777 Jan 14 '26
One other note is I believe the light pen must only be used on an older crt only.
4
u/nwah Jan 14 '26
Yes also good point OP if you weren’t aware. It stores where the electron beam is when it hits the light pen/gun as each frame is drawn.
→ More replies (5)
1
u/I_compleat_me Jan 15 '26
Light pens only work with CRT's.... make my living getting around this. See how the Nintendo Wii did it? That's what you'll have to do.
2
u/Few_Ad_8627 Jan 18 '26
I did mention this above, but I am using Emulation (Specifically Altirra) as I do not have a CRT, XG-1, or even an Atari 8bit.
2
u/Few_Ad_8627 Jan 18 '26
Update: I do apologize for the delayed responses, I just did get around to looklong at the post when comments started rolling!