[solved] Damned bullets

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

[solved] Damned bullets

Postby EstTeeEfEm » Tue Jun 09, 2015 8:58 pm

Hi all,

considering how far i've got, this shouldn't be a problem but it appears my brains have fallen out ..?!

Multiple bullets!

Yes, i know i need a 2d array but its been so long since I've done this that I have plain forgotten how to do multiple bullets and it *should* be easy? In STOS I have had a few goes at this and ended up with either 10 bullets that follow the Y axis every vbl, which looks interesting in its own right lol or 10 bullets located at 0,0 that dont move ! Its now starting to try my patience a little :P

(Bear in mind this is the closest i've got and after a few attempts the code looks foul now!)
The Code....

Code: Select all

10 load "shipbob.mbk",1
30 key off : curs off : hide : mode 0 : R=palt(start(1))
50 dim BUL_X(10) : dim BUL_Y(10)
60 dim BUL_FIRED(10) : BUL_EXIST=0
70 rem
90 PX=100 : PY=100 : P_SPD=2 : BUL_SPD=5
110 for X=1 to 10
130 BUL_X(X)=-20
150 BUL_Y(X)=-20
170 BUL_FIRED(X)=0
190 next X
210 J=joy
230 bob 0,0,320,200,0,1
250 logic=back
270 bob logic,start(1),1,PX,PY,0
290 screen swap : wait vbl
310 wipe logic
330 if inkey$=" " then default : end
350 if jup then gosub 550
370 if jdown then gosub 670
390 if jleft then gosub 790
410 if jright then gosub 910
430 for A=1 to 10
450 bob logic,start(1),9,BUL_X(A),BUL_Y(A),0
470 BUL_X(A)=BUL_X(A)+BUL_SPD
490 if BUL_X(A)>320 then BUL_X(A)=-20
492 if BUL_EXIST<>0 then BUL_Y(BUL_EXIST)=PY
510 next A
520 if fire then BUL_EXIST=BUL_EXIST+1
525 if BUL_EXIST>10 then BUL_EXIST=10
530 goto 270
550 rem **************************************
570 rem **  Player Moves UP
590 rem **************************************
610 PY=PY-P_SPD
630 if PY<0 then PY=0
650 return
670 rem **************************************
690 rem **  Player Moves DOWN
710 rem **************************************
730 PY=PY+P_SPD
750 if PY>168 then PY=168
770 return
790 rem **************************************
810 rem **  Player Moves LEFT
830 rem **************************************
850 PX=PX-P_SPD
870 if PX<0 then PX=0
890 return
910 rem **************************************
930 rem **  Player Moves RIGHT
950 rem **************************************
970 PX=PX+P_SPD
990 if PX>288 then PX=288
1010 return


Attached is the ship_bob file im using in MBK... any help with this would be awesome, or if someone wants to code the Subrout then kudos to them ;)

It uses the missing link extension and nothing else..

Thanks guys...
You do not have the required permissions to view the files attached to this post.
Last edited by EstTeeEfEm on Tue Jun 09, 2015 10:16 pm, edited 1 time in total.

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

Damned bullets [SOLVED]

Postby EstTeeEfEm » Tue Jun 09, 2015 10:16 pm

Just solved it.. if anyone can work this out they can use it as a starting point!

Code: Select all

100 load "shipbob.mbk",1
200 key off : curs off : hide : mode 0 : R=palt(start(1))
300 PX=100 : PY=100 : P_SPD=2 : BUL_SPD=20
400 dim BULX(20)
500 dim BULY(20)
505 dim BUL(20)
510 for A=1 to 20
515 DEL=0
520 BULX(A)=-20
530 BULY(A)=-20
535 BUL(A)=0
536 BULEXIST=0
540 next A
600 bob 0,0,320,200,0,1
700 logic=back
800 rem ** Main Loop routine ***********************************
900 bob logic,start(1),1,PX,PY,0
910 for A=1 to 20
920 bob logic,start(1),9,BULX(A),BULY(A),0
925 BULX(A)=BULX(A)+BUL_SPD
930 next A
1000 screen swap : wait vbl
1100 wipe logic
1200 if inkey$=" " then default : end
1300 if jup then gosub 1800
1400 if jdown then gosub 2400
1500 if jleft then gosub 3000
1600 if jright then gosub 3600
1610 if fire and DEL=0 then gosub 4200
1620 inc DEL : if DEL>5 then DEL=0
1630 locate 0,0 : print DEL
1700 goto 900
1800 rem **************************************
1900 rem **  Player Moves UP
2000 rem **************************************
2100 PY=PY-P_SPD
2200 if PY<0 then PY=0
2300 return
2400 rem **************************************
2500 rem **  Player Moves DOWN
2600 rem **************************************
2700 PY=PY+P_SPD
2800 if PY>168 then PY=168
2900 return
3000 rem **************************************
3100 rem **  Player Moves LEFT
3200 rem **************************************
3300 PX=PX-P_SPD
3400 if PX<0 then PX=0
3500 return
3600 rem **************************************
3700 rem **  Player Moves RIGHT
3800 rem **************************************
3900 PX=PX+P_SPD
4000 if PX>288 then PX=288
4100 return
4200 rem **************************************
4300 rem **  Player Shoots Bullets
4400 rem **************************************
4409 rem
4500 inc BULEXIST : if BULEXIST=20 then BULEXIST=0
4510 if BUL(BULEXIST)<>1 then BULX(BULEXIST)=PX+32 : BULY(BULEXIST)=PY-12 : BUL(BULEXIST)=1
4520 if BULX(BULEXIST)>320 then BUL(BULEXIST)=0
4525 rem
4530 return


Enjoy... its a starting point and nothing else, the delay needs playing with and a not fire needs adding to stop the delay increase..


Social Media

     

Return to “STOS”

Who is online

Users browsing this forum: No registered users and 1 guest