Jump to content

A bit of code .....


Retrospect

Recommended Posts

! CODE TO BE PASTED INTO EXTENDED BASIC AND COMPILED USING THE WILHELM COMPILER
! OTHERWISE IT'LL BE RAAAAAATHER SLOOOOOOW

! * GRAPHICS DEFS
! 36     PLAYER SHIP
! 40    PLAYER MISSILE

10 CALL CHAR(36,"00000006061E7FFFFFFFFF0000000000000000C0C0F0FCFEFEFEFE0000000000")
20 CALL CHAR(40,"0103030101010000000000000000000000808000000000000000000000000000")

! * SCREEN CLEAR, BLACK SCREEN, MAGNIFYx3 SPRITES
100 CALL CLEAR :: CALL SCREEN(2)::CALL MAGNIFY(3)

! * GET THE SPRITES ON SCREEN
1000 CALL SPRITE(#1,36,7,160,120,#2,40,16,160,120)::PF=0::PFS=0::RC=0


! * MAIN LOOP
1100 GOSUB 4100        ! JOY
1105 GOSUB 4200        ! FIRE PRESSED?
1110 GOSUB 4300        ! INCREMENT PLAYER MISSILE?
1115 GOSUB 4400        ! PLAYER FIRING SOUND?
1120 GOSUB 4500        ! RECOIL?
1125 GOTO 1100

! * JOY

! CALL JOYSTICK AND FIRE KEY.  IF RECOIL IS *NOT* ACTIVE THEN IT WILL MOVE THE SHIP ACCORDINGLY IN AUTOMOTION
! IF YOU'RE FIRING, IT MOVES *ONLY* THE SHIP OTHERWISE BOTH SHIP AND MISSILE MOVE.

4100 CALL JOYST(1,JY,JX) :: CALL KEY(1,K,ST) :: IF RC=0 THEN 4105 ELSE 4199
4105 IF PF=0 THEN 4110 ELSE 4120
4110 CALL MOTION(#1,0,JY*6,#2,0,JY*6)::GOTO 4199
4120 CALL MOTION(#1,0,JY*6)
4199 RETURN

! * FIRE PRESSED?

! SCAN K FOR VALUE 18 WHICH IS THE FIRE KEY ON JOYSTICK (Q OR TAB ON EMULATORS)
! GETS POSITION OF SHIP AND SETS RECOIL, RECOIL TICKER, RECOIL TIMER "X", PLAYER FIRING SOUND, PLAYER FIRING SOUND TICKER

4200 IF PF=1 THEN 4299 ELSE IF RC=1 THEN 4299
4205 IF K=18 THEN 4210 ELSE 4299
4210 CALL POSITION(#2,F1,F2)::PF=1::RC=1::RCT=0::RCX=0::PFS=1::PFST=0
4299 RETURN

! * INCREMENT PLAYER MISSILE?

! PF "PLAYER FIRING" ON OR OFF.
! F1 IS THE ROW POSITION OF THE PLAYER MISSILE, THIS DECREMENTS IN STEPS OF 8 PIXELS AT A TIME.
! F2 THE THE COLUMN POSITION THIS DOES NOT ALTER DURING MISSILE TRAVEL, IT'S ATTAINED FROM YOUR SHIP'S POSITION WHEN YOU FIRED.
! WHEN F1 REACHES <8 IT RELOCATES THE MISSILE WITHIN THE PLAYER SHIP AND SWITCHES OFF "PF"

4300 IF PF=0 THEN 4399
4310 F1=F1-8::IF F1<8 THEN 4315 ELSE 4320
4315 CALL POSITION(#1,P1,P2)::CALL LOCATE(#2,P1,P2)::PF=0::GOTO 4399
4320 CALL LOCATE(#2,F1,F2)
4399 RETURN

! * PLAYER FIRING SOUND?

! IT'S NOT THE BEST SOUND REALLY.  BUT YOU CAN ALTER IT.
! PFS IS "PLAYER FIRING SOUND" ON OR OFF ... PFST IS THE "TICKER" TO TAKE IT THROUGH 4 STAGES.
! THE FOURTH STAGE TURNS OFF PFS

4400 IF PFS=0 THEN 4499
4405 PFST=PFST+1 :: ON PFST GOTO 4410,4420,4430,4440
4410 VL=6000::GOTO 4450
4420 VL=5000::GOTO 4450
4430 VL=4000::GOTO 4450
4440 PFS=0::CALL SOUND(-1,110,30)::GOTO 4499
4450 CALL SOUND(-500,110,30,110,30,VL,30,-8,0)
4499 RETURN

! * RECOIL?

! RC IS THE RECOIL ON OR OFF VARIABLE.
! RCX IS USED TO SLOW DOWN THE ANIMATION OF THE RECOIL AND CAN BE ALTERED AS SUCH TO MAKE IT QUICKER OR SLOWER
! RCT IS THE "TICKER" TO STEP THROUGH STAGES OF RECOIL
! P1,P2 ARE THE PLAYER CALLED POSITION
! Z STORES A NUMBER TO ADD TO THE SHIP'S POSITION, THIS CHANGES THROUGH STEPS WITH "ON RCT" AT LINE 4505

4500 IF RC=0 THEN 4599
4501 RCX=RCX+1::IF RCX>1 THEN 4505 ELSE 4599
4505 RCX=0::RCT=RCT+1 :: ON RCT GOTO 4510,4520,4530,4540,4550,4560,4508
4506 CALL POSITION(#1,P1,P2)::CALL LOCATE(#1,P1+Z,P2)::GOTO 4599
4507 CALL POSITION(#1,P1,P2)::CALL LOCATE(#1,P1-Z,P2)::GOTO 4599
4508 RC=0::GOTO 4599
4510 Z=3::GOTO 4506
4520 Z=2::GOTO 4506
4530 Z=1::GOTO 4506
4540 Z=1::GOTO 4507
4550 Z=2::GOTO 4507
4560 Z=3::GOTO 4507
4599 RETURN
 

 

-------------------------------------------------------------

Copy this code into Classic99 and use the wilhelm compiler that you get with it , to compile it ... see what it does.  

Alter the code, experiment with the code, play with it, make something with it ... put in enemies and checks for collisions ... enemy movement routines .... Have fun!

Link to comment
Share on other sites

Here we have a little more code added to the example above.  We now have four animated enemies with the ability to fire. As yet, no collision detection or death routines are in place.

 

! CODE TO BE PASTED INTO EXTENDED BASIC AND COMPILED USING THE WILHELM COMPILER
! OTHERWISE IT'LL BE RAAAAAATHER SLOOOOOOW


! E$ ARRAY FOR ENEMY ANIMATION
1 DIM E$(11)::FOR Q=1 TO 11::READ E$(Q)::NEXT Q
2 DATA 00000003075FBFFF030000000000000000000080C0FCFEFE8000000000000000,00000003076FDFFF030000000000000000000080C0FCFEFE8000000000000000
3 DATA 000000030777EFFF030000000000000000000080C0FCFEFE8000000000000000,00000003057DFBFF030000000000000000000080C0FCFEFE8000000000000000
4 DATA 00000003067EFEFF030000000000000000000080C0FCFEFE8000000000000000,00000003077FFFFF030000000000000000000080407CBEFE8000000000000000
5 DATA 00000003077FFFFF030000000000000000000080C0BCDEFE8000000000000000,00000003077FFFFF030000000000000000000080C0DCEEFE8000000000000000
6 DATA 00000003077FFFFF030000000000000000000080C0ECF6FE8000000000000000,00000003077FFFFF030000000000000000000080C0F4FAFE8000000000000000
7 DATA 00000003077FFFFF030000000000000000000080C0FCFEFE8000000000000000


! * GRAPHICS DEFS
! 36     PLAYER SHIP
! 40    PLAYER MISSILE
! 96    ENEMY (USES THE E$(XX) ARRAY FOR ANIMATION)
! 100     ENEMY MISSILE


10 CALL CHAR(36,"00000006061E7FFFFFFFFF0000000000000000C0C0F0FCFEFEFEFE0000000000")
20 CALL CHAR(40,"0103030101010000000000000000000000808000000000000000000000000000")
25 CALL CHAR(96,E$(1))
30 CALL CHAR(100,"0000000000000000000103010301010000000000000000000080008000800000")


! * ENEMY ALIVE ARRAY, 4 ELEMENTS, FOR FOUR ENEMIES
50 DIM EA(4)


! * SCREEN CLEAR, BLACK SCREEN, MAGNIFYx3 SPRITES
100 CALL CLEAR :: CALL SCREEN(2)::CALL MAGNIFY(3)

! * GET THE SPRITES ON SCREEN, PLAYING NOT FIRING (PF=0), NO RECOIL (RC=0), ENEMY NOT F‏IRING (EF=0)
! NOTE: EVEN NULL VARIABLES HAVE TO BE DECLARED FOR THE COMPILER OTHERWISE IT'LL CRASH.
! ET=0 , THIS IS THE ENEMY TIMER FOR ANIMATION.  ETM=4 IS MAXIMUM DELAY VALUE, IT TAKES INTO ACCOUNT IF PLAYER IS FIRING AND ALTERS ACCORDINGLY
! WAIT=1 , MEANS WE ARE WAITING FOR AN ENEMY, SHORT DELAY BEFORE THEY APPEAR WITH "WT" INCREMENTING UP TO 100 THEN WAIT=0 AND ENEMIES ON SCREEN
! EP DECLARED AS NILL, THIS IS FOR ANIMATING ENEMY PATTERNS

1000 CALL SPRITE(#1,36,7,160,120,#2,40,16,160,120)::PF=0::PFS=0::RC=0::EF=0::ET=0::ETM=4::WAIT=1::WT=0::EP=0


! * MAIN LOOP
1100 GOSUB 4100        ! JOY
1105 GOSUB 4200        ! FIRE PRESSED?
1110 GOSUB 4300        ! INCREMENT PLAYER MISSILE?
1115 GOSUB 4400        ! PLAYER FIRING SOUND?
1120 GOSUB 4500        ! RECOIL?
1125 GOSUB 4600        ! WAITING FOR ENEMY?
1130 GOSUB 4700        ! ANIMATE ENEMY?
1135 GOSUB 4800        ! CAN ENEMY FIRE?
1140 GOSUB 4900        ! TRACK ENEMY MISSILE?
1145 GOTO 1100

! * JOY

! CALL JOYSTICK AND FIRE KEY.  IF RECOIL IS *NOT* ACTIVE THEN IT WILL MOVE THE SHIP ACCORDINGLY IN AUTOMOTION
! IF YOU'RE FIRING, IT MOVES *ONLY* THE SHIP OTHERWISE BOTH SHIP AND MISSILE MOVE.

4100 CALL JOYST(1,JY,JX) :: CALL KEY(1,K,ST) :: IF RC=0 THEN 4105 ELSE 4199
4105 IF PF=0 THEN 4110 ELSE 4120
4110 CALL MOTION(#1,0,JY*6,#2,0,JY*6)::GOTO 4199
4120 CALL MOTION(#1,0,JY*6)
4199 RETURN

! * FIRE PRESSED?

! SCAN K FOR VALUE 18 WHICH IS THE FIRE KEY ON JOYSTICK (Q OR TAB ON EMULATORS)
! GETS POSITION OF SHIP AND SETS RECOIL, RECOIL TICKER, RECOIL TIMER "X", PLAYER FIRING SOUND, PLAYER FIRING SOUND TICKER
! WHEN PLAYER MISSILE IS ACTIVE, ETM (MAX DELAY FOR ENEMY ANIMATIONS) IS SET TO HALF IT'S NORMAL VALUE.

4200 IF PF=1 THEN 4299 ELSE IF RC=1 THEN 4299
4205 IF K=18 THEN 4210 ELSE 4299
4210 CALL POSITION(#2,F1,F2)::PF=1::RC=1::RCT=0::RCX=0::PFS=1::PFST=0::ETM=2
4299 RETURN


! * INCREMENT PLAYER MISSILE?

! PF "PLAYER FIRING" ON OR OFF.
! F1 IS THE ROW POSITION OF THE PLAYER MISSILE, THIS DECREMENTS IN STEPS OF 8 PIXELS AT A TIME.
! F2 THE THE COLUMN POSITION THIS DOES NOT ALTER DURING MISSILE TRAVEL, IT'S ATTAINED FROM YOUR SHIP'S POSITION WHEN YOU FIRED.
! WHEN F1 REACHES <8 IT RELOCATES THE MISSILE WITHIN THE PLAYER SHIP AND SWITCHES OFF "PF"
! IF "PF" IS NILL, THEN "ETM" IS SET BACK TO 4 

4300 IF PF=0 THEN 4399
4310 F1=F1-8::IF F1<8 THEN 4315 ELSE 4320
4315 CALL POSITION(#1,P1,P2)::CALL LOCATE(#2,P1,P2)::PF=0::ETM=4::GOTO 4399
4320 CALL LOCATE(#2,F1,F2)
4399 RETURN

! * PLAYER FIRING SOUND?

! IT'S NOT THE BEST SOUND REALLY.  BUT YOU CAN ALTER IT.
! PFS IS "PLAYER FIRING SOUND" ON OR OFF ... PFST IS THE "TICKER" TO TAKE IT THROUGH 4 STAGES.
! THE FOURTH STAGE TURNS OFF PFS

4400 IF PFS=0 THEN 4499
4405 PFST=PFST+1 :: ON PFST GOTO 4410,4420,4430,4440
4410 VL=6000::GOTO 4450
4420 VL=5000::GOTO 4450
4430 VL=4000::GOTO 4450
4440 PFS=0::CALL SOUND(-1,110,30)::GOTO 4499
4450 CALL SOUND(-500,110,30,110,30,VL,30,-8,0)
4499 RETURN


! * RECOIL?

! RC IS THE RECOIL ON OR OFF VARIABLE.
! RCX IS USED TO SLOW DOWN THE ANIMATION OF THE RECOIL AND CAN BE ALTERED AS SUCH TO MAKE IT QUICKER OR SLOWER
! RCT IS THE "TICKER" TO STEP THROUGH STAGES OF RECOIL
! P1,P2 ARE THE PLAYER CALLED POSITION
! Z STORES A NUMBER TO ADD TO THE SHIP'S POSITION, THIS CHANGES THROUGH STEPS WITH "ON RCT" AT LINE 4505

4500 IF RC=0 THEN 4599
4501 RCX=RCX+1::IF RCX>1 THEN 4505 ELSE 4599
4505 RCX=0::RCT=RCT+1 :: ON RCT GOTO 4510,4520,4530,4540,4550,4560,4508
4506 CALL POSITION(#1,P1,P2)::CALL LOCATE(#1,P1+Z,P2)::GOTO 4599
4507 CALL POSITION(#1,P1,P2)::CALL LOCATE(#1,P1-Z,P2)::GOTO 4599
4508 RC=0::GOTO 4599
4510 Z=3::GOTO 4506
4520 Z=2::GOTO 4506
4530 Z=1::GOTO 4506
4540 Z=1::GOTO 4507
4550 Z=2::GOTO 4507
4560 Z=3::GOTO 4507
4599 RETURN


! * WAITING FOR ENEMY?

! WAIT AND WT ARE USED HERE FOR A SHORT DELAY UNTIL YOU SEE THE ENEMY RATHER THAN THEM JUST BEING THERE RIGHT FROM THE START

4600 IF WAIT=0 THEN 4699
4605 WT=WT+1 :: IF WT>99 THEN 4610 ELSE 4699
4610 WAIT=0 :: WT=0 :: EA(1)=1::EA(2)=1::EA(3)=1::EA(4)=1 
4615 CALL SPRITE(#3,96,16,32,16,0,16,#4,96,16,64,32,0,16,#5,96,16,96,48,0,16,#6,96,16,128,64,0,16)
4699 RETURN


! * ANIMATE ENEMY?
!
! ET IS USED HERE, COUNTS UP TO ETM AND THEN INCREMENTS THE ENEMY USING CALL CHAR ALONG WITH "EP" BEING INCREMENTED UP TO 11 
! FIRST OFF, CHECK IF THEY'RE ACTUALLY HERE OR NOT ....

4700 IF WAIT=1 THEN 4799
4705 ET=ET+1 :: IF ET>ETM THEN 4710 ELSE 4799
4710 ET=0::EP=EP+1 :: IF EP>11 THEN EP=1
4715 CALL CHAR(96,E$(EP))
4799 RETURN


! * CAN ENEMY FIRE?
!
! IF ENEMY IS NOT ALREADY FIRING, THEN LET A RANDOM ENEMY THAT IS "ALIVE" FIRE A MISSILE
! AGAIN CHECK IF WAIT IS ON OR NOT OTHERWISE IT'S FAIRLY POINTLESS.....

4800 IF EF=1 THEN 4899 
4805 IF WAIT=1 THEN 4899
4810 R=INT(4*RND)+1 :: IF EA(R)=1 THEN 4815 ELSE 4899
4815 CALL POSITION(#R+2,EF1,EF2)::CALL SPRITE(#7,100,6,EF1,EF2,32,0)::EF=1
4899 RETURN

! * TRACK ENEMY MISSILE?
!
! IF THE ENEMY HAS ALREADY FIRED THEN WE SHOULD REALLY CHECK WHERE THE MISSILE IS AS IT'S IN AUTOMOTION.
! DOESN'T LOOK GOOD IF IT WRAPS THE SCREEN.... WE'LL PUT COLLISION DETECTION IN LATER, FOR ENEMY MISSILE vs PLAYER SHIP
! AND VICE-VERSA...

4900 IF EF=0 THEN 4999
4905 CALL POSITION(#7,C1,C2)::IF C1>180 THEN 4910 ELSE 4999
4910 CALL DELSPRITE(#7)::EF=0
4999 RETURN

 

 

 

 

Link to comment
Share on other sites

We now have enemy - player missile collisions as well as player - enemy missile collisions.  For now, when player "dies" it just jumps back to main loop after player explosion.

In near future, "lives" , "score" , and "best score" will be displayed and the variables needed for those will be introduced and used.

 

! CODE TO BE PASTED INTO EXTENDED BASIC AND COMPILED USING THE WILHELM COMPILER
! OTHERWISE IT'LL BE RAAAAAATHER SLOOOOOOW


! E$ ARRAY FOR ENEMY ANIMATION
1 DIM E$(11)::FOR Q=1 TO 11::READ E$(Q)::NEXT Q
2 DATA 00000003075FBFFF030000000000000000000080C0FCFEFE8000000000000000,00000003076FDFFF030000000000000000000080C0FCFEFE8000000000000000
3 DATA 000000030777EFFF030000000000000000000080C0FCFEFE8000000000000000,00000003057DFBFF030000000000000000000080C0FCFEFE8000000000000000
4 DATA 00000003067EFEFF030000000000000000000080C0FCFEFE8000000000000000,00000003077FFFFF030000000000000000000080407CBEFE8000000000000000
5 DATA 00000003077FFFFF030000000000000000000080C0BCDEFE8000000000000000,00000003077FFFFF030000000000000000000080C0DCEEFE8000000000000000
6 DATA 00000003077FFFFF030000000000000000000080C0ECF6FE8000000000000000,00000003077FFFFF030000000000000000000080C0F4FAFE8000000000000000
7 DATA 00000003077FFFFF030000000000000000000080C0FCFEFE8000000000000000


! * GRAPHICS DEFS
! 36     PLAYER SHIP
! 40    PLAYER MISSILE
! 96    ENEMY (USES THE E$(XX) ARRAY FOR ANIMATION)
! 100     ENEMY MISSILE
! 104    ENEMY EXPLOSION
! 108    PLAYER EXPLOSION BIT


10 CALL CHAR(36,"00000006061E7FFFFFFFFF0000000000000000C0C0F0FCFEFEFEFE0000000000")
20 CALL CHAR(40,"0103030101010000000000000000000000808000000000000000000000000000")
25 CALL CHAR(96,E$(1))
30 CALL CHAR(100,"0000000000000000000103010301010000000000000000000080008000800000")
35 CALL CHAR(104,"0000040210080130010810020400000000809020040840864008042090800000")
40 CALL CHAR(108,"00000000000001010000000000000000000000000080C0C08000000000000000")

! * ENEMY ALIVE ARRAY, 4 ELEMENTS, FOR FOUR ENEMIES
50 DIM EA(4)


! * SCREEN CLEAR, BLACK SCREEN, MAGNIFYx3 SPRITES
100 CALL CLEAR :: CALL SCREEN(2)::CALL MAGNIFY(3)

! * GET THE SPRITES ON SCREEN, PLAYING NOT FIRING (PF=0), NO RECOIL (RC=0), ENEMY NOT F‏IRING (EF=0)
! NOTE: EVEN NULL VARIABLES HAVE TO BE DECLARED FOR THE COMPILER OTHERWISE IT'LL CRASH.
! ET=0 , THIS IS THE ENEMY TIMER FOR ANIMATION.  ETM=4 IS MAXIMUM DELAY VALUE, IT TAKES INTO ACCOUNT IF PLAYER IS FIRING AND ALTERS ACCORDINGLY
! WAIT=1 , MEANS WE ARE WAITING FOR AN ENEMY, SHORT DELAY BEFORE THEY APPEAR WITH "WT" INCREMENTING UP TO 100 THEN WAIT=0 AND ENEMIES ON SCREEN
! EP DECLARED AS NILL, THIS IS FOR ANIMATING ENEMY PATTERNS
! XP1 DECLARED AS NILL, THIS IS FOR ENEMY EXPLODING
! XP1T IS USED FOR A TIMER FOR XP WHEN IT IS "ON"
! XP2 DECLARED AS NILL, THIS IS FOR PLAYER EXPLOSION.  IF XP2 IS 1, THEN PLAYER CANNOT ACCESS JOYSTICK OR FIRE KEY

1000 CALL SPRITE(#1,36,7,160,120,#2,40,16,160,120)::PF=0::PFS=0::RC=0::EF=0::ET=0::ETM=4::WAIT=1::WT=0::EP=0::XP1=0::XP2=0

! * MAIN LOOP
1100 GOSUB 4100        ! JOY
1105 GOSUB 4200        ! FIRE PRESSED?
1110 GOSUB 4300        ! INCREMENT PLAYER MISSILE?
1115 GOSUB 4400        ! PLAYER FIRING SOUND?
1120 GOSUB 4500        ! RECOIL?
1125 GOSUB 4600        ! WAITING FOR ENEMY?
1130 GOSUB 4700        ! ANIMATE ENEMY?
1135 GOSUB 4800        ! CAN ENEMY FIRE?
1140 GOSUB 4900        ! TRACK ENEMY MISSILE?
1145 GOSUB 5000        ! ENEMY EXPLODING?
1150 GOSUB 5100        ! PLAYER EXPLODING?
1199 GOTO 1100

! * JOY

! CALL JOYSTICK AND FIRE KEY.  IF RECOIL IS *NOT* ACTIVE THEN IT WILL MOVE THE SHIP ACCORDINGLY IN AUTOMOTION
! IF YOU'RE FIRING, IT MOVES *ONLY* THE SHIP OTHERWISE BOTH SHIP AND MISSILE MOVE.
! IF XP2 IS SET TO 1 THEN PLAYER CANNOT ACCESS JOYSTICK OR FIRE KEY

4100 IF XP2=1 THEN 4199
4101 CALL JOYST(1,JY,JX) :: CALL KEY(1,K,ST) :: IF RC=0 THEN 4105 ELSE 4199
4105 IF PF=0 THEN 4110 ELSE 4120
4110 CALL MOTION(#1,0,JY*6,#2,0,JY*6)::GOTO 4199
4120 CALL MOTION(#1,0,JY*6)
4199 RETURN

! * FIRE PRESSED?

! SCAN K FOR VALUE 18 WHICH IS THE FIRE KEY ON JOYSTICK (Q OR TAB ON EMULATORS)
! GETS POSITION OF SHIP AND SETS RECOIL, RECOIL TICKER, RECOIL TIMER "X", PLAYER FIRING SOUND, PLAYER FIRING SOUND TICKER
! WHEN PLAYER MISSILE IS ACTIVE, ETM (MAX DELAY FOR ENEMY ANIMATIONS) IS SET TO HALF IT'S NORMAL VALUE.

4200 IF PF=1 THEN 4299 ELSE IF RC=1 THEN 4299
4205 IF K=18 THEN 4210 ELSE 4299
4210 CALL POSITION(#2,F1,F2)::PF=1::RC=1::RCT=0::RCX=0::PFS=1::PFST=0::ETM=2
4299 RETURN


! * INCREMENT PLAYER MISSILE?

! PF "PLAYER FIRING" ON OR OFF.
! F1 IS THE ROW POSITION OF THE PLAYER MISSILE, THIS DECREMENTS IN STEPS OF 8 PIXELS AT A TIME.
! F2 THE THE COLUMN POSITION THIS DOES NOT ALTER DURING MISSILE TRAVEL, IT'S ATTAINED FROM YOUR SHIP'S POSITION WHEN YOU FIRED.
! WHEN F1 REACHES <8 IT RELOCATES THE MISSILE WITHIN THE PLAYER SHIP AND SWITCHES OFF "PF"
! IF "PF" IS NILL, THEN "ETM" IS SET BACK TO 4 
! NOW LINE 4320 HAS BEEN MODIFIED TO SUB TO A CALL COINC

4300 IF PF=0 THEN 4399
4310 F1=F1-8::IF F1<8 THEN 4315 ELSE 4320
4315 CALL POSITION(#1,P1,P2)::CALL LOCATE(#2,P1,P2)::PF=0::ETM=4::GOTO 4399
4320 CALL LOCATE(#2,F1,F2)::IF WAIT=0 THEN GOSUB 8000
4399 RETURN


! * PLAYER FIRING SOUND?

! IT'S NOT THE BEST SOUND REALLY.  BUT YOU CAN ALTER IT.
! PFS IS "PLAYER FIRING SOUND" ON OR OFF ... PFST IS THE "TICKER" TO TAKE IT THROUGH 4 STAGES.
! THE FOURTH STAGE TURNS OFF PFS

4400 IF PFS=0 THEN 4499
4405 PFST=PFST+1 :: ON PFST GOTO 4410,4420,4430,4440
4410 VL=6000::GOTO 4450
4420 VL=5000::GOTO 4450
4430 VL=4000::GOTO 4450
4440 PFS=0::CALL SOUND(-1,110,30)::GOTO 4499
4450 CALL SOUND(-500,110,30,110,30,VL,30,-8,0)
4499 RETURN


! * RECOIL?

! THE RECOIL IS *NOT* DONE IS PLAYER IS GOING THROUGH EXPLOSION ROUTINE
! RC IS THE RECOIL ON OR OFF VARIABLE.
! RCX IS USED TO SLOW DOWN THE ANIMATION OF THE RECOIL AND CAN BE ALTERED AS SUCH TO MAKE IT QUICKER OR SLOWER
! RCT IS THE "TICKER" TO STEP THROUGH STAGES OF RECOIL
! P1,P2 ARE THE PLAYER CALLED POSITION
! Z STORES A NUMBER TO ADD TO THE SHIP'S POSITION, THIS CHANGES THROUGH STEPS WITH "ON RCT" AT LINE 4505

4500 IF RC=0 THEN 4599 ELSE IF XP2=1 THEN 4599
4501 RCX=RCX+1::IF RCX>1 THEN 4505 ELSE 4599
4505 RCX=0::RCT=RCT+1 :: ON RCT GOTO 4510,4520,4530,4540,4550,4560,4508
4506 CALL POSITION(#1,P1,P2)::CALL LOCATE(#1,P1+Z,P2)::GOTO 4599
4507 CALL POSITION(#1,P1,P2)::CALL LOCATE(#1,P1-Z,P2)::GOTO 4599
4508 RC=0::GOTO 4599
4510 Z=3::GOTO 4506
4520 Z=2::GOTO 4506
4530 Z=1::GOTO 4506
4540 Z=1::GOTO 4507
4550 Z=2::GOTO 4507
4560 Z=3::GOTO 4507
4599 RETURN


! * WAITING FOR ENEMY?

! WAIT AND WT ARE USED HERE FOR A SHORT DELAY UNTIL YOU SEE THE ENEMY RATHER THAN THEM JUST BEING THERE RIGHT FROM THE START

4600 IF WAIT=0 THEN 4699
4605 WT=WT+1 :: IF WT>99 THEN 4610 ELSE 4699
4610 WAIT=0 :: WT=0 :: EA(1)=1::EA(2)=1::EA(3)=1::EA(4)=1 
4615 CALL SPRITE(#3,96,16,32,16,0,16,#4,96,16,64,32,0,16,#5,96,16,96,48,0,16,#6,96,16,128,64,0,16)
4699 RETURN


! * ANIMATE ENEMY?
!
! ET IS USED HERE, COUNTS UP TO ETM AND THEN INCREMENTS THE ENEMY USING CALL CHAR ALONG WITH "EP" BEING INCREMENTED UP TO 11 
! FIRST OFF, CHECK IF THEY'RE ACTUALLY HERE OR NOT ....

4700 IF WAIT=1 THEN 4799
4705 ET=ET+1 :: IF ET>ETM THEN 4710 ELSE 4799
4710 ET=0::EP=EP+1 :: IF EP>11 THEN EP=1
4715 CALL CHAR(96,E$(EP))
4799 RETURN


! * CAN ENEMY FIRE?
!
! IF ENEMY IS NOT ALREADY FIRING, THEN LET A RANDOM ENEMY THAT IS "ALIVE" FIRE A MISSILE
! AGAIN CHECK IF WAIT IS ON OR NOT OTHERWISE IT'S FAIRLY POINTLESS.....

4800 IF EF=1 THEN 4899 
4805 IF WAIT=1 THEN 4899
4810 R=INT(4*RND)+1 :: IF EA(R)=1 THEN 4815 ELSE 4899
4815 CALL POSITION(#R+2,EF1,EF2)::CALL SPRITE(#7,100,6,EF1,EF2,32,0)::EF=1
4899 RETURN

! * TRACK ENEMY MISSILE?
!
! IF THE ENEMY HAS ALREADY FIRED THEN WE SHOULD REALLY CHECK WHERE THE MISSILE IS AS IT'S IN AUTOMOTION.
! DOESN'T LOOK GOOD IF IT WRAPS THE SCREEN....
! THIS ROUTINE NOW CHECKS FOR ENEMY MISSILE vs PLAYER SHIP.  IF THERE'S A COLLIDE THEN XP2 IS SET TO 1 AND XP2T IS USED FOR IT'S TIMER


4900 IF EF=0 THEN 4999
4905 CALL POSITION(#7,C1,C2)::IF C1>180 THEN 4910 ELSE 4920
4910 CALL DELSPRITE(#7)::EF=0::GOTO 4999
4920 CALL COINC(#7,#1,8,H)::IF H=-1 THEN 4925 ELSE 4999
4925 CALL DELSPRITE(#7)::EF=0::CALL MOTION(#1,0,0)::CALL DELSPRITE(#2)::PF=0
4930 CALL SOUND(-1,110,30)::CALL POSITION(#1,P1,P2)
4935 CALL SPRITE(#11,108,16,P1,P2,-16,-16,#12,108,16,P1,P2,-19,-12,#13,108,16,P1,P2,-19,12,#14,108,16,P1,P2,-16,16)
4940 XP2=1::XP2T=0::CALL DELSPRITE(#1)
4999 RETURN

! * ENEMY EXPLODING?
!
! IF XP1 IS 1 , THEN XPT INCREMENTS UNTIL 20 AND THEN TURNS OFF THE EXPLOSION SPRITE

5000 IF XP1=0 THEN 5099
5005 XP1T=XP1T+1 :: IF XP1T>19 THEN 5010 ELSE 5099
5010 CALL DELSPRITE(#10)::XP1=0
5099 RETURN

! * PLAYER EXPLODING?
!
! IF XP2 IS SET TO 1 THEN THE PLAYER IS GOING THROUGH EXPLOSION SEQUENCE.  XP2T IS THE TIMER FOR THIS.
! WHEN EXPLOSION IS FINISHED, FOR NOW THERE'S A DELAY THEN IT GOES BACK TO THE START OF THE MAIN LOOP.
! NORMALLY WE'D LOSE A LIFE AT THIS POINT, AND IF ALL LIVES ARE LOST THEN IT WOULD BE GAME OVER.

5100 IF XP2=0 THEN 5199
5105 XP2T=XP2T+1 :: IF XP2T>32 THEN 5110 ELSE 5199
5110 XP2=0::CALL DELSPRITE(#11,#12,#13,#14)::FOR DELAY=1 TO 5000::NEXT DELAY::CALL DELSPRITE(ALL)::GOTO 1000
5199 RETURN

! * CALL COINC ROUTINE FOR PLAYER MISSILE

! GOES THROUGH A LOOP OF 1 TO 4, IF THE EA() ARRAY FOR "L" IS SET TO ZERO IT'S IGNORED AND MOVES TO THE NEXT.
! IF THE EA() ARRAY IS SET TO 1 AND THE ENEMY WAS ACTIVE, AND THAT ENEMY IS HIT, THEN IT EA(XX) IS SET TO NILL AND EXPLOSION IS SET TO 1
! ALSO PLAYER MISSILE IS TURNED OFF IF AN ENEMY IS HIT, THIS IS DONE BY SUBBING TO 4315 WHICH HAS IT'S OWN RETURN SO WE CAN DO IT THAT WAY.

8000 FOR L=1 TO 4
8001 IF EA(L)=1 THEN 8002 ELSE 8010
8002 CALL COINC(#2,#2+L,8,H)::IF H=-1 THEN 8003 ELSE 8010
8003 CALL MOTION(#2+L,0,0)::CALL POSITION(#2+L,P1,P2)::CALL SPRITE(#10,104,16,P1,P2)::CALL DELSPRITE(#2+L)
8004 XP1=1::XP1T=0::EA(L)=0::PF=0::GOSUB 4315 
8010 NEXT L
8099 RETURN


 

 

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...