Automatic Auto/Rapid fire

STOS-related stuff in here please

Moderators: exxos, simonsunnyboy, Mug UK, Zorro 2, Moderator Team

EstTeeEfEm
Captain Atari
Captain Atari
Posts: 299
Joined: Mon May 04, 2015 9:02 pm

Automatic Auto/Rapid fire

Postby EstTeeEfEm » Fri Mar 11, 2016 9:14 am

How do I stop bullets from firing constantly..?

As in you have to hit the fire button to fire a bullet... if you just hold the button down it fires continuously and I really don't want that lol..

Albeit in early stages, I've included the source to the routine so that any helpers out there can exactly tell me what to do lol.

I am sure it involves reading the joystick exactly but rather than mess around for hours maybe someone knows this one already?

- - no poking holes in my horrible source - its only just been started -:P --

Code: Select all

10 key off : curs off : hide : mode 0
20 erase 1
30 reserve as screen 15 : load "playarea.pi1",15 : get palette (15)
40 wait vbl
50 load "player_b.mbk",1
60 load "bullet_j.mbk",2
70 bob 0,0,256,200,0,1
80 joey 0,0,256,200,0,0,1
90 logic=back
100 PX=100 : PY=100 : IMG=1 : SPD=2
110 dim FRD(5) : dim BULX(5) : dim BULY(5)
120 for X=1 to 5
130 BULX(X)=-20 : BULY(X)=-20
140 next X
150 BUL_SPD=15
160 J=joy
170 rem *********************************************
180 J=joy
190 blit start(15),256,0,320,200,logic,256,0
200 gosub 340
230 gosub 460
290 screen swap : wait vbl : wash logic,0,0,256,200
300 if inkey$=" " then default : end
310 goto 170
320 rem ******************************************
330 rem ** player movements                     **
340 rem ******************************************
350 IMG=1
360 if jright then PX=PX+SPD : IMG=2
370 if jleft then PX=PX-SPD : IMG=0
380 if jup then PY=PY-SPD
390 if jdown then PY=PY+SPD
400 if PX<0 then PX=0
410 if PX>232 then PX=232
420 if PY<0 then PY=0
430 if PY>172 then PY=172
440 bob logic,start(1),IMG,PX,PY,0
450 return
460 rem ******************************************
470 rem ** player fires bullets                 **
480 rem ******************************************
490 if fire and FRD(1)=0 then FRD(1)=1 : BULX(1)=PX+4 : BULY(1)=PY-4 : goto 540
500 if fire and FRD(2)=0 then FRD(2)=1 : BULX(2)=PX+4 : BULY(2)=PY-4 : goto 540
510 if fire and FRD(3)=0 then FRD(3)=1 : BULX(3)=PX+4 : BULY(3)=PY-4 : goto 540
520 if fire and FRD(4)=0 then FRD(4)=1 : BULX(4)=PX+4 : BULY(4)=PY-4 : goto 540
530 if fire and FRD(5)=0 then FRD(5)=1 : BULX(5)=PX+4 : BULY(5)=PY-4 : goto 540
540 for X=1 to 5
550 joey logic,start(2),0,BULX(X),BULY(X),1,0
560 if FRD(X)=1 then BULY(X)=BULY(X)-BUL_SPD
570 if BULY(X)<-20 then BULY(X)=-20 : FRD(X)=0
580 next X
600 return


I did try reading the "J" Exactly using "print J" but this gives spurious results to say the least, esp when movement occurs

User avatar
exxos
Hardware Guru
Hardware Guru
Posts: 4933
Joined: Fri Mar 28, 2003 8:36 pm
Location: England
Contact:

Re: Automatic Auto/Rapid fire

Postby exxos » Fri Mar 11, 2016 10:11 am

If your bullet travels upwards for example (off the screen) then assuming BULY is your Y location, check when it goes negative...

If fire and BULY<0 then do stuff..

That way you can only fire again when the bullet goes off screen.

In fact you could skip the 5 fire checking lines and just have like
485 if BULY>0 then goto 540 (or whatever line skips past all the checking stuff)

or maybe
485 if BULY>0 then return.

I've not looked at your code to closely :)
4MB STFM 1.44 FD- VELOCE+ 020 STE - Falcon 030 CT60 - Atari 2600 - Atari 7800 - Gigafile - SD Floppy Emulator - PeST - various clutter

http://www.exxoshost.co.uk/atari/ All my hardware guides - mods - games - STOS
http://www.exxoshost.co.uk/atari/last/storenew/ - All my hardware mods for sale - Please help support by making a purchase.
http://ataristeven.exxoshost.co.uk/Steem.htm Latest Steem Emulator

EstTeeEfEm
Captain Atari
Captain Atari
Posts: 299
Joined: Mon May 04, 2015 9:02 pm

Re: Automatic Auto/Rapid fire

Postby EstTeeEfEm » Fri Mar 11, 2016 4:41 pm

Aah, i know what you mean but thats not what I meant... i mean having to hammer the fire button rather than just holding it... i wanted a NOT pressed scenario in order to stop a user simply holding the fire button down...

if " J <> " doesn't work...

User avatar
exxos
Hardware Guru
Hardware Guru
Posts: 4933
Joined: Fri Mar 28, 2003 8:36 pm
Location: England
Contact:

Re: Automatic Auto/Rapid fire

Postby exxos » Fri Mar 11, 2016 4:44 pm

EstTeeEfEm wrote:Aah, i know what you mean but thats not what I meant... i mean having to hammer the fire button rather than just holding it... i wanted a NOT pressed scenario in order to stop a user simply holding the fire button down...

if " J <> " doesn't work...


hmmm, so you want the user to actually let go of the fire button before a new bullet is fired then ?
4MB STFM 1.44 FD- VELOCE+ 020 STE - Falcon 030 CT60 - Atari 2600 - Atari 7800 - Gigafile - SD Floppy Emulator - PeST - various clutter

http://www.exxoshost.co.uk/atari/ All my hardware guides - mods - games - STOS
http://www.exxoshost.co.uk/atari/last/storenew/ - All my hardware mods for sale - Please help support by making a purchase.
http://ataristeven.exxoshost.co.uk/Steem.htm Latest Steem Emulator

EstTeeEfEm
Captain Atari
Captain Atari
Posts: 299
Joined: Mon May 04, 2015 9:02 pm

Re: Automatic Auto/Rapid fire

Postby EstTeeEfEm » Fri Mar 11, 2016 4:46 pm

thats the one... ;)

User avatar
exxos
Hardware Guru
Hardware Guru
Posts: 4933
Joined: Fri Mar 28, 2003 8:36 pm
Location: England
Contact:

Re: Automatic Auto/Rapid fire

Postby exxos » Fri Mar 11, 2016 4:48 pm

setup
FL=0

main loop

If fire and FL=0 then FL=10: fire missile
... draw screen and other stuff...
if bulletY<0 and fire=0 then FL=0


Not sure if that would work like that, but thats the idea. Just to add a FLag which is never set back to zero until fire=0 (not pressed)
4MB STFM 1.44 FD- VELOCE+ 020 STE - Falcon 030 CT60 - Atari 2600 - Atari 7800 - Gigafile - SD Floppy Emulator - PeST - various clutter

http://www.exxoshost.co.uk/atari/ All my hardware guides - mods - games - STOS
http://www.exxoshost.co.uk/atari/last/storenew/ - All my hardware mods for sale - Please help support by making a purchase.
http://ataristeven.exxoshost.co.uk/Steem.htm Latest Steem Emulator

EstTeeEfEm
Captain Atari
Captain Atari
Posts: 299
Joined: Mon May 04, 2015 9:02 pm

Re: Automatic Auto/Rapid fire

Postby EstTeeEfEm » Fri Mar 11, 2016 4:55 pm

Slight tinkering with the idea but it works.... quite slow and not always reactive but i'll figure it out.. see? just another pair of eyes for something obvious ;)

User avatar
exxos
Hardware Guru
Hardware Guru
Posts: 4933
Joined: Fri Mar 28, 2003 8:36 pm
Location: England
Contact:

Re: Automatic Auto/Rapid fire

Postby exxos » Fri Mar 11, 2016 5:00 pm

EstTeeEfEm wrote:Slight tinkering with the idea but it works.... quite slow and not always reactive but i'll figure it out.. see? just another pair of eyes for something obvious ;)


Is the fire button to fire the bullet being checked enough times ? Its the only reason I can think why it would be lagging. Unless the fire=0 part isn't being checked often enough to reset the ready to fire flag ?
4MB STFM 1.44 FD- VELOCE+ 020 STE - Falcon 030 CT60 - Atari 2600 - Atari 7800 - Gigafile - SD Floppy Emulator - PeST - various clutter

http://www.exxoshost.co.uk/atari/ All my hardware guides - mods - games - STOS
http://www.exxoshost.co.uk/atari/last/storenew/ - All my hardware mods for sale - Please help support by making a purchase.
http://ataristeven.exxoshost.co.uk/Steem.htm Latest Steem Emulator

EstTeeEfEm
Captain Atari
Captain Atari
Posts: 299
Joined: Mon May 04, 2015 9:02 pm

Re: Automatic Auto/Rapid fire

Postby EstTeeEfEm » Fri Mar 11, 2016 5:01 pm

Well, its checked everytime the loop runs so i think it might be a compiled/interpreted thing going on..

EstTeeEfEm
Captain Atari
Captain Atari
Posts: 299
Joined: Mon May 04, 2015 9:02 pm

Re: Automatic Auto/Rapid fire

Postby EstTeeEfEm » Fri Mar 11, 2016 5:03 pm

yeah, compiled its as fast as it can be ;) no lag or mused shots so to speak

User avatar
exxos
Hardware Guru
Hardware Guru
Posts: 4933
Joined: Fri Mar 28, 2003 8:36 pm
Location: England
Contact:

Re: Automatic Auto/Rapid fire

Postby exxos » Fri Mar 11, 2016 5:05 pm

EstTeeEfEm wrote:yeah, compiled its as fast as it can be ;) no lag or mused shots so to speak


Awesome :) :cheers:
4MB STFM 1.44 FD- VELOCE+ 020 STE - Falcon 030 CT60 - Atari 2600 - Atari 7800 - Gigafile - SD Floppy Emulator - PeST - various clutter

http://www.exxoshost.co.uk/atari/ All my hardware guides - mods - games - STOS
http://www.exxoshost.co.uk/atari/last/storenew/ - All my hardware mods for sale - Please help support by making a purchase.
http://ataristeven.exxoshost.co.uk/Steem.htm Latest Steem Emulator

EstTeeEfEm
Captain Atari
Captain Atari
Posts: 299
Joined: Mon May 04, 2015 9:02 pm

Re: Automatic Auto/Rapid fire

Postby EstTeeEfEm » Fri Mar 11, 2016 5:08 pm

lol MUSED? shots?? ... bloody auto correct..

User avatar
Mikefulton
Captain Atari
Captain Atari
Posts: 169
Joined: Sun Nov 29, 2015 10:27 am

Re: Automatic Auto/Rapid fire

Postby Mikefulton » Sat Mar 12, 2016 8:56 am

What you want is a concept called "Debounce"

Basically, after you detect a joystick button being PRESSED, you set a flag that prevents the next pass from shooting again.

When the flag is set, you're testing for the button to be RELEASED. When that happens, you clear the flag and go back to looking for the next button press.

EstTeeEfEm
Captain Atari
Captain Atari
Posts: 299
Joined: Mon May 04, 2015 9:02 pm

Re: Automatic Auto/Rapid fire

Postby EstTeeEfEm » Sat Mar 12, 2016 9:51 am

What you want is a concept called "Debounce"


Didnt know there was an actual term for it lol.. got it sorted though, be aware, when progs are not compiled it doesnt work properly :roll:


Social Media

     

Return to “STOS”

Who is online

Users browsing this forum: No registered users and 1 guest