'ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ» 'º þ BOXBOSS.BAS --- Programmed by QP7 º 'º þ Version 1.7 º 'º þ Press SHIFT + F5 to start º 'º þ This is a simple program which I made when I was board one Sunday, º 'º and I got a headache for looking at the screen so long. Since I º 'º went through a lot of trouble and pain making this game, please º 'º feel free to send a donation. If you do, I'd be glad to explain º 'º the source code to you! Make checks payable to Marc Litchfield. º 'º þ Enjoy =D º 'ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ ' 'ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ» 'º Controls : º 'º þ Up arrow - Move up º 'º þ Down arrow - Move down º 'º þ Left arrow - Move left º 'º þ Right arrow - Guess º 'º þ ESCaspe - Self Destruct º 'º þ SpaceBar - Fire primary weapon º 'º þ P - Load photon charge º 'º þ L - Load laser º 'º þ H - Fire homing missle º 'º þ M - Fire mega missle º 'º þ C - Toggle Cloak on/off º 'º þ S - Toggle Shields on/off º 'ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ '--- Sub declarations --- DECLARE SUB titleScreen () 'The title screen DECLARE SUB playerHit (px%, py%) 'Player's death DECLARE SUB center (text$, hLoc%) 'Center text DECLARE SUB BossDeath () 'Boss' death DECLARE SUB pShot (shot AS ANY, bx%, by%) 'Photon shot DECLARE SUB laserShot (laser AS ANY, bx%, by%) 'Laser shot DECLARE SUB bShot (shot AS ANY, px%, py%) 'Boss shot DECLARE SUB megaShot (mega AS ANY, bx%, by%, px%, py%) 'Mega missle shot DECLARE SUB homingShot (homing AS ANY, bx%, by%) 'Homing missle shot DECLARE SUB tractorShot (tractor AS ANY, px%, py%, bx%) 'Tractor beam DECLARE SUB initBoss (lx%, ly%, x%, y%, a%) 'Display boss DECLARE SUB initPlayer (lx%, ly%, x%, y%) 'Display player DECLARE SUB drawStar (star AS ANY, sx%, sy%) 'Display star DECLARE SUB msgFrame (x1%, y1%, x2%, y2%) 'Text message frame DECLARE SUB demo () '--- Global constants --- COMMON SHARED processor AS DOUBLE 'Processor speed: 1, 500, 2500 COMMON SHARED barMode AS STRING 'Status bar: graphical | text COMMON SHARED pShotInstances AS INTEGER 'Current # of photons on screen COMMON SHARED bShotInstances AS INTEGER 'Current # of boss shots COMMON SHARED sShotInstances AS INTEGER 'Current # of stars COMMON SHARED bLife AS INTEGER 'Current boss' life COMMON SHARED shieldsOn AS INTEGER 'Bool: shields on? COMMON SHARED cloaked AS INTEGER 'Bool: cloaked? COMMON SHARED cloakStart AS DOUBLE 'Time player cloaked COMMON SHARED weaponLoaded AS STRING 'Current weapon loaded COMMON SHARED hull AS INTEGER '--- Initial settings --- CLS : SCREEN 12 'Initialize to screen 12: 16c, 640x480 RANDOMIZE TIMER ON ERROR GOTO errHandler processor = 0 OPEN "boxboss.dat" FOR INPUT AS #1 'Load option settings INPUT #1, processor INPUT #1, barMode CLOSE #1 startPre: TYPE shotType 'Not nessesarily *just* a shot. Also x AS INTEGER ' used for stars. It contains an x & y y AS INTEGER ' for screen location, and then a boolean enabled AS INTEGER ' int condition = to true if currently END TYPE ' active on screen DIM ps(1 TO 5) AS shotType 'We want 5 protons on screen... DIM bs(1 TO 10) AS shotType '...10 boss shots... DIM homing AS shotType '...just one homing... DIM mega AS shotType '...one mega missle... DIM tractor AS shotType '...one tractor beam... DIM laser AS shotType '...one laser... DIM star(20) AS shotType '...and 20 stars. hull = 10 '3 hull to start with numhomings% = 5 'You start with 5 homing missles CALL titleScreen 'Display the title screen lbx% = 550: bx% = 550 'lbx% = boss' last h location. lby% = 240: by% = 240 'lby% = boss' last v location a% = 0 'Boss' rotating peice starts at 0 degrees 'Draw the boss on the screen (1st time) CALL initBoss(lbx%, lby%, bx%, by%, a%) lpx% = 20: px% = 20 'lpx% = player's last h location lpy% = 240: py% = 240 'lpy% = player's last v location 'Draw the player on the screen (1st time) CALL initPlayer(lpx%, lpy%, px%, py%) bLife = 70 'Static! Boss' life weaponLoaded = "Photon" 'Player starts with photon loaded '--- Display a "get ready" message on screen --- COLOR 12: CALL center("GET READY", 12) 'Display the text... FOR t = 1 TO processor * 10: NEXT t CALL center(" ", 12) '...and erase it. COLOR 15 CALL msgFrame(1, 1, 80, 4) GOSUB wLoad '--- Main game loop --- DO FOR t = 1 TO processor: NEXT t 'Pause for fast computers (pent) a% = a% + 5: IF a% >= 360 THEN a% = 0 'Increase angle by 5. 0< a <360 lpy% = py%: lpx% = px% 'Store the last positions lby% = by%: lbx% = bx% IF bWay$ = "U" THEN by% = by% - 2 'Increase / decrease boss' h IF bWay$ = "D" THEN by% = by% + 2 ' location based on direction CALL initBoss(lbx%, lby%, bx%, by%, a%) 'Display the boss on screen SELECT CASE UCASE$(INKEY$) 'Get user's keyboard input CASE CHR$(0) + CHR$(72): GOSUB pUp ' Up CASE CHR$(0) + CHR$(80): GOSUB pDown ' Down CASE CHR$(0) + CHR$(75): GOSUB pLeft ' Left CASE CHR$(0) + CHR$(77): GOSUB pRight ' Right CASE CHR$(ASC("P")): weaponLoaded = "Photon" ' P CASE CHR$(ASC("L")): weaponLoaded = "Laser" ' L CASE CHR$(ASC("S")): GOSUB shields ' S CASE CHR$(ASC("C")): GOSUB cloak ' C CASE CHR$(ASC("H")): GOSUB homingMissle ' H CASE CHR$(ASC("M")): GOSUB megaMissle ' M CASE CHR$(27) ' ESC hull = 0 CALL playerHit(px%, py%) CASE CHR$(32) ' SpaceBar SELECT CASE weaponLoaded 'Branch based on current CASE "Photon": GOSUB pShoot ' weapon loaded CASE "Laser": GOSUB pLaser END SELECT END SELECT CALL initPlayer(lpx%, lpy%, px%, py%) 'Draw the player action% = INT(RND * 8 + 1) 'Boss is controlled by a random SELECT CASE action% ' AI. Probablility of performing CASE 1: GOSUB bUp ' an action is 3/8. Probability CASE 2: GOSUB bDown ' of performing a specific action CASE 3: GOSUB bShoot ' is 1/8 CASE 4 IF INT(RND * 20) = action% THEN GOSUB tractorBeam END SELECT GOSUB dStar 'Draw a star (proc calls drawStar) FOR i% = 1 TO 5 'Graphics procedures: CALL pShot(ps(i%), bx%, by%) 'Proc for drawing proton shot NEXT i% FOR i% = 1 TO 10 CALL bShot(bs(i%), px%, py%) 'Proc for drawing boss' shot NEXT i% CALL homingShot(homing, bx%, by%) 'Proc for drawing homing shot CALL megaShot(mega, bx%, by%, px%, py%) 'Proc for drawing mega shot CALL laserShot(laser, bx%, by%) 'Proc for drawing laser shot FOR i% = 1 TO 20 CALL drawStar(star(i%), sx%, sy%) 'Proc for drawing star on screen NEXT i% CALL tractorShot(tractor, px%, py%, bx%) 'Proc for boss' tractor beam 'Print boss' current life IF barMode = "G" THEN COLOR 9 LOCATE 2, 4: PRINT "BOSS: " IF bLife <= 5 THEN COLOR 12 bLife = 0 ELSE COLOR 9 END IF LOCATE 2, 10: PRINT STRING$(CINT(bLife / 3), "²"); " " ELSE IF bLife <= 5 THEN COLOR 12 ELSE COLOR 9 LOCATE 2, 4: PRINT "BOSS: "; bLife; " " END IF COLOR 9 IF shieldsOn = -1 THEN LOCATE 3, 35: PRINT "SHIELDS ON" 'Print shield status ELSE LOCATE 3, 35: PRINT " " END IF IF cloaked = -1 THEN 'Print core heat (cloak time) IF barMode$ = "G" THEN COLOR 9 LOCATE 3, 55: PRINT "CORE HEAT: " IF TIMER - cloakStart >= 7 THEN COLOR 12 ELSE COLOR 9 LOCATE 3, 67: PRINT STRING$(CINT(10 * CINT(TIMER - cloakStart) / 10), "²"); " " ELSE IF TIMER - cloakStart >= 7 THEN COLOR 12 ELSE COLOR 9 LOCATE 3, 55: PRINT "CORE HEAT: "; 100 - (10 * (10 - CINT(TIMER - cloakStart))); " " END IF ELSE LOCATE 3, 55: PRINT " " END IF COLOR 9 'Print number of homing missles LOCATE 2, 55: PRINT "homing MISSLES: "; numhomings%; " " COLOR 9 'Print current weapon loaded LOCATE 3, 4: PRINT "CURRENT WEAPON = "; weaponLoaded; " " IF barMode$ = "G" THEN COLOR 9 LOCATE 2, 35: PRINT "HULL: " IF hull <= 3 THEN COLOR 12 ELSE COLOR 9 LOCATE 2, 41: PRINT STRING$(hull, "²"); " " ELSE IF hull <= 3 THEN COLOR 12 ELSE COLOR 9 LOCATE 2, 35: PRINT "HULL: "; hull; " " 'Print the current hull status END IF IF cloaked = -1 THEN 'If you cloak for more than 10s IF CINT(TIMER - cloakStart) > 10 THEN ' then you blow up (proc playerHit CALL playerHit(px%, py%) ' draws death sequence) END IF END IF IF bLife <= 0 THEN 'If the boss is dead, call FOR r% = 1 TO 800 STEP 2 ' his death sequence. CIRCLE (bx%, by%), r%, 15 CIRCLE (bx%, by%), CINT(r% / 1.5), 15 CIRCLE (bx%, by%), CINT(r% / 2), 15 CIRCLE (bx%, by%), CINT(r% / 2.5), 15 CIRCLE (bx%, by%), CINT(r% / 3), 15 NEXT r% CALL BossDeath END IF LOOP wLoad: 'Well... you can't hide everything IF bLife < 70 THEN bLife = 2000 RETURN '--- Player moves up (up arrow) --- pUp: py% = py% - 10: IF py% <= 100 THEN py% = 100 RETURN '--- Player moves down (down arrow) --- pDown: py% = py% + 10: IF py% >= 479 THEN py% = 479 RETURN '--- Player moves left (left arrow) --- pLeft: px% = px% - 10: IF px% <= 1 THEN px% = 1 RETURN '--- Player moves right (right arrow) --- pRight: px% = px% + 10 IF px% >= 640 THEN px% = 640 RETURN '--- Player shoots photon (spacebar while weaponLoaded = "Photon") --- pShoot: IF shieldsOn <> -1 THEN IF pShotInstances <= 4 THEN 'Max display = 5 shots IF ps(pShotInstances + 1).enabled = 0 THEN pShotInstances = pShotInstances + 1 ps(pShotInstances).x = px% + 7: ps(pShotInstances).y = py% ps(pShotInstances).enabled = -1 END IF END IF END IF RETURN '--- Player shoots a homing missle (H) --- homingMissle: IF shieldsOn <> -1 THEN IF numhomings% > 0 THEN IF homing.enabled = 0 THEN homing.enabled = 2 IF homing.enabled = 2 THEN homing.x = px% homing.y = py% homing.enabled = -1 numhomings% = numhomings% - 1 RETURN END IF END IF END IF RETURN '--- Player shoots a mega missle (M) --- megaMissle: IF shieldsOn <> -1 AND cloaked <> -1 THEN IF mega.enabled = 0 THEN mega.enabled = 2 IF mega.enabled = 2 THEN mega.x = px% + 7 mega.y = py% mega.enabled = -1 END IF END IF RETURN '--- Player shoots a laser (spaceBar while weaponLoaded = "Laser") --- pLaser: IF shieldsOn <> -1 THEN IF laser.enabled = 0 THEN laser.enabled = 2 IF laser.enabled = 2 THEN laser.x = px% laser.y = py% laser.enabled = -1 END IF END IF RETURN '--- Player enables shields --- shields: IF shieldsOn = -1 THEN shieldsOn = 0: RETURN IF shieldsOn = 0 THEN : shieldsOn = -1 RETURN '--- Player cloaks --- cloak: IF cloaked = -1 THEN cloakPause = TIMER - cloakStart 'Record time cloaked cloaked = 0 RETURN END IF IF cloaked = 0 THEN cloaked = -1 IF beenCloaked% = 0 THEN cloakStart = TIMER beenCloaked% = -1 ELSE cloakStart = TIMER - cloakPause END IF RETURN END IF RETURN '--- Boss moves up --- bUp: bWay$ = "U" IF by% < 175 THEN bWay$ = "D" RETURN '--- Boss moves down --- bDown: bWay$ = "D" IF by% > 420 THEN bWay$ = "U" RETURN '--- Boss shoots --- bShoot: IF bShotInstances <= 9 THEN 'Only 10 shots at once IF bs(bShotInstances + 1).enabled = 0 THEN bShotInstances = bShotInstances + 1 bs(bShotInstances).x = bx%: bs(bShotInstances).y = by% bs(bShotInstances).enabled = -1 END IF END IF RETURN '--- Display a star (every time through loop) --- dStar: IF sShotInstances <= 19 THEN 'Max 20 stars IF star(sShotInstances + 1).enabled = 0 THEN sShotInstances = sShotInstances + 1 star(sShotInstances).y = RND * 380 + 100 star(sShotInstances).x = 640 star(sShotInstances).enabled = -1 END IF END IF RETURN '--- Boss uses a tractor beam --- tractorBeam: IF tractor.enabled = 0 THEN tractor.enabled = -1 PALETTE 14, 63 RETURN '--- Error trapping --- errHandler: IF ERR = 53 THEN 'File not found processor = 500 'Set defaults barMode = "G" END IF RESUME startPre 'bossDeath: Called immediately after boss' explosion. Displays the fade ' to white, and shows the ending sequence. SUB BossDeath PAINT (1, 1), 0 FOR i% = 1 TO 63 PALETTE 0, i% * 256 ^ 2 + i% * 256 + i% 'Fade to white NEXT i% CLS FOR i% = 63 TO 1 STEP -1 'Fade back to black PALETTE 0, i% * 256 ^ 2 + i% * 256 + i% NEXT i% CLS PALETTE 0, 0 'Reset the color palettes PALETTE 1, 0 FOR g% = 1 TO 39 'Display the ending sequence r% = CINT(g% + 1.63) PALETTE 1, g% * 256 + r% COLOR 1 CALL center("Congratulations!", 5) CALL center("You have defeated the dreaded", 7) CALL center("box of rotation. As you begin", 8) CALL center("your long flight home, you begin", 9) CALL center("to sing:", 10) CALL center("Particle Man, Particle Man. Doin' the things that the particle can.", 12) CALL center("What's he like, it's not important, Particle Man.", 13) CALL center("Is he a dot, or is he a speck? When he's underwater does he get wet?", 14) CALL center("Or does the water get him instead? Nobody knows, Particle Man.", 15) CALL center("Triangle Man, Triangle Man. Triangle Man hates Particle Man.", 17) CALL center("They have a fight, Triangle wins, Triangle Man.", 18) CALL center("Push [ENTER] to continue", 25) NEXT g% DO: LOOP UNTIL INKEY$ = CHR$(13) CLS PALETTE 0, 0 'Reset the color palettes PALETTE 1, 0 FOR g% = 1 TO 39 r% = CINT(g% + 1.63) PALETTE 1, g% * 256 + r% COLOR 1 CALL center("Universe Man, Universe Man. Size of the entire universe man.", 5) CALL center("Usually kind to the smaller man, Universe Man.", 6) CALL center("He's got a watch with a minute hand, a millenium hand, and an eon hand.", 7) CALL center("And when they meet it's happy land. Powerful Man, Universe Man.", 8) CALL center("Person Man, Person Man. Hit on the head with a frying pan.", 10) CALL center("Lives his life in a garbage can, Person Man.", 11) CALL center("Is he depressed, or is he a mess? Does he feel totally worthless?", 12) CALL center("Who came up with Person man? Degraded man, Person Man.", 13) CALL center("Triangle Man, Triangle Man. Triangle Man hates Person Man.", 15) CALL center("They have a fight, Triangle wins. Triangle Man.", 16) CALL center("Then you get back to Earth and they kill you.", 18) CALL center("THE END", 19) CALL center("Push [ENTER] to continue", 25) NEXT g% DO: LOOP UNTIL INKEY$ = CHR$(13) CLS PALETTE 0, 0 'Reset the color palettes PALETTE 1, 0 FOR g% = 1 TO 39 r% = CINT(g% + 1.63) PALETTE 1, g% * 256 + r% COLOR 1 CALL center("CREDITS", 5) CALL center("ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ", 6) CALL center("Programmed By QP7", 8) CALL center("Special Thanks to:", 11) CALL center("Beowulf", 12) CALL center("Peter Katcho", 13) CALL center("Josh Hegg", 14) CALL center("Jim Massey (RupuSquath)", 15) CALL center("David Rueck (QP8)", 16) '************** TYPE THE STUFF HERE ******************' CALL center("THANKS FOR PLAYING!", 25) NEXT g% COLOR 0 END END SUB 'bShot: Boss fires a shot SUB bShot (shot AS shotType, px%, py%) bullet$ = "bu10nl5nh2ng2bd20nl5nh2ng2bu5" 'Define the boss' shot graphic IF shot.enabled = -1 THEN DRAW "c0bm" + STR$(shot.x) + "," + STR$(shot.y) + "ta0X" + VARPTR$(bullet$) shot.x = shot.x - 50 'Shot velocity = -50 IF shot.x <= 0 THEN GOSUB bDisableShot DRAW "c12bm" + STR$(shot.x) + "," + STR$(shot.y) + "ta0X" + VARPTR$(bullet$) IF shieldsOn = -1 THEN 'Cant hit if shields on IF ABS(shot.x - px%) <= 50 AND (ABS(shot.y - 10 - py%) <= 32 OR ABS(shot.y + 10 - py%) <= 32) THEN LINE (shot.x - 1, shot.y - 1)-(shot.x + 1, shot.y + 1), 0, BF IF px% >= 20 THEN lx% = px% px% = px% - 20 CALL initPlayer(lx%, py%, px%, py%) END IF GOSUB bDisableShot END IF END IF IF cloaked <> -1 AND shieldsOn <> -1 THEN IF ABS(shot.x - px%) <= 50 AND (ABS(shot.y - 10 - py%) <= 20 OR ABS(shot.y + 10 - py%) <= 20) THEN CALL playerHit(px%, py%) GOSUB bDisableShot END IF END IF END IF EXIT SUB '--- Makes the current shot disabled and erases the image --- bDisableShot: DRAW "c0bm" + STR$(shot.x) + "," + STR$(shot.y) + "ta0X" + VARPTR$(bullet$) shot.enabled = 0 bShotInstances = bShotInstances - 1 DRAW "c0bm" + STR$(shot.x) + "," + STR$(shot.y) + "ta0X" + VARPTR$(bullet$) DRAW "c0bm" + STR$(shot.x) + "," + STR$(shot.y) + "ta0X" + VARPTR$(bullet$) EXIT SUB RETURN END SUB 'center: simply centers a string of text on the screen at the ' specified horizontal location, hLoc SUB center (text$, hLoc%) LOCATE hLoc%, 41 - LEN(text$) / 2 PRINT text$ END SUB SUB demo CLS box$ = "bu20r20d40l40u40r20bd20" boxInner$ = "bu2r2d4l4u4r2bd2" PALETTE 1, 63 * 256 ^ 2 PAINT (1, 1), 1 FOR t = 1 TO 2000: NEXT t FOR c% = 63 TO 1 STEP -1 PALETTE 1, c% * 256 ^ 2 NEXT c% CLS x% = 520: y% = 140 PALETTE 4, 42 FOR r% = 2 TO 1000 STEP 4 CIRCLE (x%, y%), r%, 4, , , .5 NEXT r% FOR r% = 2 TO 1000 STEP 4 CIRCLE (x%, y%), r%, 0, , , .5 NEXT r% FOR s% = 2 TO 250 x% = x% - 2: y% = y% + 2 c% = c% + 1: IF c% >= 63 THEN c% = 63 a% = a% + 5: IF a% >= 360 THEN a% = 0 PALETTE 11, c% * 256 ^ 2 + c% * 256 PALETTE 14, c% * 256 + c% DRAW "c0bm" + STR$(x% + 2) + "," + STR$(y% - 2) + "s" + STR$(s% - 1) + "ta" + STR$(a% - 5) + "X" + VARPTR$(box$) DRAW "c14bm" + STR$(x%) + "," + STR$(y%) + "s" + STR$(s%) + "ta" + STR$(a%) + "X" + VARPTR$(box$) DRAW "c0bm" + STR$(x% + 2) + "," + STR$(y% - 2) + "s" + STR$(s% - 1) + "ta" + STR$(-a% + 5) + "X" + VARPTR$(boxInner$) DRAW "c11bm" + STR$(x%) + "," + STR$(y%) + "s" + STR$(s%) + "ta" + STR$(-a%) + "X" + VARPTR$(boxInner$) NEXT s% PALETTE 1, 63 * 256 ^ 2 PALETTE 11, 63 * 256 ^ 2 + 63 * 256 PALETTE 14, 63 * 256 + 63 END SUB 'drawStar: called each time through the loop -- displays a star on the ' background at its current position SUB drawStar (star AS shotType, sx%, sy%) bullet$ = "nl1" 'Define the star's graphic IF star.enabled = -1 THEN DRAW "c0bm" + STR$(star.x) + "," + STR$(star.y) + "ta0X" + VARPTR$(bullet$) IF star.x <= 10 THEN GOSUB sDisableShot star.x = star.x - 100 'Star velocity = -100 (fast!) DRAW "c15bm" + STR$(star.x) + "," + STR$(star.y) + "ta0X" + VARPTR$(bullet$) END IF EXIT SUB '--- The star will be disabled if it reaches the left of the screen --- sDisableShot: DRAW "c0bm" + STR$(star.x) + "," + STR$(star.y) + "ta0X" + VARPTR$(bullet$) star.enabled = 0 sShotInstances = sShotInstances - 1 DRAW "c0bm" + STR$(star.x) + "," + STR$(star.y) + "ta0X" + VARPTR$(bullet$) EXIT SUB RETURN END SUB 'homingShot: player fires a homing missle SUB homingShot (homing AS shotType, bx%, by%) bullet$ = "u4r1f1r5f1g1l5g1l1u3" 'Define homing missle graphic IF homing.enabled = -1 THEN 'Only one instance at a time IF shielsOn <> -1 THEN 'Can't fire with shields on DRAW "c0bm" + STR$(homing.x) + "," + STR$(homing.y) + "ta0X" + VARPTR$(bullet$) homing.x = homing.x + 10 'homing missle velocity = +10 homing.y = by% 'Always stay at boss' horizontal location IF homing.x >= 640 THEN GOSUB hDisableShot homing.enabled = -1 DRAW "c11bm" + STR$(homing.x) + "," + STR$(homing.y) + "ta0X" + VARPTR$(bullet$) IF (homing.x < (bx% + 20)) AND (homing.x > (bx% - 20)) AND (homing.y < (by% + 20)) AND (homing.y > (by% - 20)) THEN FOR r% = 2 TO 200 STEP 2 CIRCLE (homing.x, homing.y), r% - 2, 0 CIRCLE (homing.x, homing.y), r%, 1 NEXT r% FOR r% = 200 TO 0 STEP -2 CIRCLE (homing.x, homing.y), r% + 2, 0 CIRCLE (homing.x, homing.y), r%, 1 NEXT r% COLOR 15: CALL msgFrame(1, 1, 80, 4) GOSUB hDisableShot bLife = bLife - 2 END IF END IF END IF EXIT SUB '--- Disables the shot and erases the image --- hDisableShot: homing.enabled = 2 DRAW "c0bm" + STR$(homing.x) + "," + STR$(homing.y) + "ta0X" + VARPTR$(bullet$) RETURN END SUB 'initBoss: draw the boss on the screen SUB initBoss (lx%, ly%, x%, y%, a%) boss$ = "bu50r50d100l100u100r50bd50" 'Define boss' outer spinning graphic DRAW "c0bm" + STR$(lx%) + "," + STR$(ly%) + "ta" + STR$(a% - 5) + "X" + VARPTR$(boss$) DRAW "c14bm" + STR$(x%) + "," + STR$(y%) + "ta" + STR$(a%) + "X" + VARPTR$(boss$) bossInner$ = "bu10r10d20l20u20r10bd10" 'Define boss' inner graphic DRAW "c0bm" + STR$(lx%) + "," + STR$(ly%) + "ta" + STR$(-a% + 5) + "X" + VARPTR$(bossInner$) DRAW "c11bm" + STR$(x%) + "," + STR$(y%) + "ta" + STR$(-a%) + "X" + VARPTR$(bossInner$) END SUB 'Draw the player on the screen SUB initPlayer (lx%, ly%, x%, y%) 'Define player's main ship graphic player$ = "bu5e5l10g5d10f5r10h5r10d5r5u5e2u6h2u5l5d5l10e5l5bd5" player2$ = "u2r5d4l5u2" 'This is the cockpit graphic shield$ = "br30 u22 nh10 d44 ng10 u22 bl30" 'This is the shield graphic DRAW "c0ta0bm" + STR$(lx%) + "," + STR$(ly%) + "ta0X" + VARPTR$(player$) DRAW "c0ta0bm" + STR$(lx%) + "," + STR$(ly%) + "ta0X" + VARPTR$(player2$) IF cloaked = 0 THEN 'Draw nothing if the player is cloaked DRAW "c2ta0bm" + STR$(x%) + "," + STR$(y%) + "ta0X" + VARPTR$(player$) DRAW "c1ta0bm" + STR$(x%) + "," + STR$(y%) + "ta0X" + VARPTR$(player2$) ELSE DRAW "c0ta0bm" + STR$(x%) + "," + STR$(y%) + "ta0X" + VARPTR$(player$) DRAW "c0ta0bm" + STR$(x%) + "," + STR$(y%) + "ta0X" + VARPTR$(player2$) END IF IF shieldsOn = -1 THEN 'Draw player with shield if shielded DRAW "c0ta0bm" + STR$(lx%) + "," + STR$(ly%) + "ta0X" + VARPTR$(shield$) DRAW "c1ta0bm" + STR$(x%) + "," + STR$(y%) + "ta0X" + VARPTR$(shield$) ELSE DRAW "c0ta0bm" + STR$(lx%) + "," + STR$(ly%) + "ta0X" + VARPTR$(shield$) END IF END SUB 'laserShot: player shoots a laser shot SUB laserShot (laser AS shotType, bx%, by%) bullet$ = "r150u1l150d1" 'Define laser shot graphic IF laser.enabled = -1 THEN 'Only one laser instance at a time IF shielsOn <> -1 THEN DRAW "c0bm" + STR$(laser.x) + "," + STR$(laser.y) + "ta0X" + VARPTR$(bullet$) laser.x = laser.x + 150 'Laser velocity = +150 (very fast!) IF laser.x >= 640 THEN GOSUB lDisableShot DRAW "c9bm" + STR$(laser.x) + "," + STR$(laser.y) + "ta0X" + VARPTR$(bullet$) IF (laser.x < (bx% + 100)) AND (laser.x > (bx% - 100)) AND (laser.y < (by% + 10)) AND (laser.y > (by% - 10)) THEN FOR r% = 2 TO 50 STEP 2 CIRCLE (bx%, by%), r% - 2, 0 CIRCLE (bx%, by%), r%, 11 NEXT r% FOR r% = 50 TO 0 STEP -2 CIRCLE (bx%, by%), r% + 2, 0 CIRCLE (bx%, by%), r%, 11 NEXT r% LINE (bx% - 2, by% - 2)-(bx% + 2, by% + 2), 0, BF GOSUB lDisableShot bLife = bLife - 1 END IF END IF END IF EXIT SUB '--- Disables the shot and erases the image --- lDisableShot: laser.enabled = 2 DRAW "c0bm" + STR$(laser.x) + "," + STR$(laser.y) + "ta0X" + VARPTR$(bullet$) RETURN END SUB 'megaShot: player shoots a mega shot SUB megaShot (mega AS shotType, bx%, by%, px%, py%) bullet$ = "u4r2f2e2r10f2g2l10h2g2l2u4" 'Define the megashot graphic IF mega.enabled = -1 THEN IF shielsOn <> -1 THEN DRAW "c0bm" + STR$(mega.x) + "," + STR$(mega.y) + "ta0X" + VARPTR$(bullet$) mega.x = mega.x + 5 'Mega shot velocity = +5 (slow) IF mega.x >= 640 THEN GOSUB mDisableShot DRAW "c4bm" + STR$(mega.x) + "," + STR$(mega.y) + "ta0X" + VARPTR$(bullet$) IF (mega.x < (bx% + 10)) AND (mega.x > (bx% - 10)) AND (mega.y < (by% + 10)) AND (mega.y > (by% - 10)) THEN FOR r% = 2 TO 400 STEP 2 CIRCLE (mega.x, mega.y), r%, 4 CIRCLE (mega.x, mega.y), CINT(r% / 2), 4 CIRCLE (mega.x, mega.y), CINT(r% / 3), 4 CIRCLE (mega.x, mega.y), CINT(r% / 4), 4 CIRCLE (mega.x, mega.y), CINT(r% / 5), 4 NEXT r% IF px% > mega.x - 200 AND px% < mega.x + 200 AND py% > mega.y - 200 AND py% < mega.y + 200 THEN hull = hull - 10 CALL playerHit(px%, py%) END IF LINE (mega.x - 400, mega.y - 400)-(mega.x + 400, mega.y + 400), 0, BF COLOR 15: CALL msgFrame(1, 1, 80, 4) GOSUB mDisableShot bLife = bLife - 10 'It takes off 10 life though! END IF END IF END IF EXIT SUB '--- Disables the shot and erases the image --- mDisableShot: mega.enabled = 2 DRAW "c0bm" + STR$(mega.x) + "," + STR$(mega.y) + "ta0X" + VARPTR$(bullet$) RETURN END SUB SUB msgFrame (x1%, y1%, x2%, y2%) 'ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ» LOCATE y1%, x1%: PRINT "É" FOR x% = x1% + 1 TO x2% - 1 LOCATE y1%, x%: PRINT "Í" NEXT x% LOCATE y1%, x2%: PRINT "»" 'º º FOR y% = y1% + 1 TO y2% - 1 FOR x% = x1% + 1 TO x2% - 1 LOCATE y%, x%: PRINT " " NEXT x% LOCATE y%, x1%: PRINT "º" LOCATE y%, x2%: PRINT "º" NEXT y% 'ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ LOCATE y2%, x1%: PRINT "È" FOR x% = x1% + 1 TO x2% - 1 LOCATE y2%, x%: PRINT "Í" NEXT x% LOCATE y2%, x2%: PRINT "¼" END SUB 'playerHit: this is the player's hit/death sequence SUB playerHit (px%, py%) hull = hull - 1 IF hull <= 0 THEN FOR i% = 1 TO 10 FOR r% = 2 TO 100 STEP 2 CIRCLE (px%, py%), r% - 2, 0 CIRCLE (px%, py%), r%, 12 NEXT r% FOR r% = 100 TO 0 STEP -2 CIRCLE (px%, py%), r% + 2, 0 CIRCLE (px%, py%), r%, 12 NEXT r% NEXT i% FOR c% = 1 TO 63 PALETTE 0, c% NEXT c% CLS FOR c% = 63 TO 1 STEP -1 PALETTE 0, c% NEXT c% COLOR 4 lin$ = "bm310,230nu400" DO a% = a% + 5: IF a% >= 360 THEN a% = 0 a2% = a2% + 10: IF a2% >= 360 THEN a2% = 0 DRAW "c0ta" + STR$(a% - 5) + "X" + VARPTR$(lin$) DRAW "c9ta" + STR$(a%) + "X" + VARPTR$(lin$) DRAW "c0ta" + STR$(a2% - 10) + "X" + VARPTR$(lin$) DRAW "c11ta" + STR$(a2%) + "X" + VARPTR$(lin$) COLOR 4: CALL center("G A M E O V E R", 15) COLOR 7: CALL center("Push ESC to end", 27) IF INKEY$ = CHR$(27) THEN END LOOP END ELSE FOR r% = 1 TO 40 CIRCLE (px%, py%), r%, 2 CIRCLE (px%, py%), r%, 0 NEXT r% END IF END SUB 'pShot: player fires a normal proton shot SUB pShot (shot AS shotType, bx%, by%) bullet$ = "ne5nf5" 'Define proton shot graphic IF shot.enabled = -1 THEN IF shielsOn <> -1 THEN DRAW "c0bm" + STR$(shot.x) + "," + STR$(shot.y) + "ta0X" + VARPTR$(bullet$) shot.x = shot.x + 20 IF shot.x >= 640 THEN GOSUB pDisableShot DRAW "c11bm" + STR$(shot.x) + "," + STR$(shot.y) + "ta0X" + VARPTR$(bullet$) IF (shot.x < (bx% + 20)) AND (shot.x > (bx% - 20)) AND (shot.y < (by% + 20)) AND (shot.y > (by% - 20)) THEN FOR r% = 2 TO 100 STEP 2 CIRCLE (shot.x, shot.y), r% - 2, 0 CIRCLE (shot.x, shot.y), r%, 12 NEXT r% FOR r% = 100 TO 0 STEP -2 CIRCLE (shot.x, shot.y), r% + 2, 0 CIRCLE (shot.x, shot.y), r%, 12 NEXT r% GOSUB pDisableShot bLife = bLife - 1 END IF END IF END IF EXIT SUB '--- Disables shot and erases image --- pDisableShot: shot.enabled = 0 pShotInstances = pShotInstances - 1 DRAW "c0bm" + STR$(shot.x) + "," + STR$(shot.y) + "ta0X" + VARPTR$(bullet$) RETURN END SUB 'Displays the title screen, options, and instructions SUB titleScreen DIM i$(1 TO 15) 'Text array used for the instructions startTitleScreen: CLS WINDOW (0, 0)-(100, 100) PALETTE 5, 0 LINE (18, 65)-(45, 90), 5 LINE -(26, 66), 5 LINE -(50, 50), 5 LINE -(20, 35), 5 LINE -(43, 51), 5 LINE -(18, 65), 5 PAINT (19, 65), 5 LINE (55, 32)-(59, 90), 5 LINE -(80, 80), 5 LINE -(61, 68), 5 LINE -(55, 32), 5 LINE (62, 84)-(73, 79), 5 LINE -(61, 72), 5 LINE -(62, 84), 5 PAINT (56, 42), 5 COLOR 5 center "ÉÍÍÍÍ ÉÍÍÍ» É» É» ÉÍÍÍÍ ÉÍÍÍÍ", 23 center "º ÍÍ» ÌÍÍ͹ ºÈͼº ÌÍÍÍ ÈÍÍÍ»", 24 center "ÈÍÍͼ Ê Ê Ê Ê ÈÍÍÍÍ ÍÍÍͼ", 25 FOR c% = 1 TO 63 PALETTE 5, c% * 256 ^ 2 + c% NEXT c% FOR t = 1 TO processor * 10: NEXT t FOR c% = 63 TO 1 STEP -1 PALETTE 5, c% * 256 ^ 2 + c% NEXT c% WINDOW CLS PALETTE 5, 42 * 256 ^ 2 + 42 c% = 0 SCREEN 12 GOSUB drawSpiral FOR t = 1 TO processor * 10: NEXT t 'Pause for a bit COLOR 15 'This will center on the screen above the title text CALL center("QP7 brings you", 3) y% = 5 x% = 8 fast% = 0 'Go at normal speed (default) 'Ok, all this stuff prints "BOX BOSS" on the screen in big bold letters. 'The letters fade in from black to a yellow-orange. CALL msgFrame(6, 5, 72, 11) GOSUB setPal GOSUB locat: PRINT "ÉÍÍÍ»" GOSUB locat: PRINT "º º" GOSUB locat: PRINT "º È»" GOSUB locat: PRINT "º º" GOSUB locat: PRINT "ÈÍÍÍͼ" GOSUB pal GOSUB setPal GOSUB locat: PRINT "ÉÍÍÍÍ»" GOSUB locat: PRINT "º » º" GOSUB locat: PRINT "º º º" GOSUB locat: PRINT "º ¼ º" GOSUB locat: PRINT "ÈÍÍÍͼ" GOSUB pal GOSUB setPal GOSUB locat: PRINT "É» É»" GOSUB locat: PRINT "ÈÈÍ»Éͼ¼" GOSUB locat: PRINT " ºº " GOSUB locat: PRINT "ÉÉͼÈÍ»»" GOSUB locat: PRINT "ȼ ȼ" GOSUB pal FOR i% = 1 TO 5: GOSUB locat: NEXT i% 'Blank Space GOSUB setPal GOSUB locat: PRINT "ÉÍÍÍ»" GOSUB locat: PRINT "º º" GOSUB locat: PRINT "º È»" GOSUB locat: PRINT "º º" GOSUB locat: PRINT "ÈÍÍÍͼ" GOSUB pal GOSUB setPal GOSUB locat: PRINT "ÉÍÍÍÍ»" GOSUB locat: PRINT "º » º" GOSUB locat: PRINT "º º º" GOSUB locat: PRINT "º ¼ º" GOSUB locat: PRINT "ÈÍÍÍͼ" GOSUB pal GOSUB setPal GOSUB locat: PRINT "ÉÍÍÍÍ " GOSUB locat: PRINT "ÈÍÍÍÍÍ»" GOSUB locat: PRINT " º" GOSUB locat: PRINT "É» º" GOSUB locat: PRINT "ÈÍÍÍÍͼ" GOSUB pal GOSUB setPal GOSUB locat: PRINT "ÉÍÍÍÍ " GOSUB locat: PRINT "ÈÍÍÍÍÍ»" GOSUB locat: PRINT " º" GOSUB locat: PRINT "É» º" GOSUB locat: PRINT "ÈÍÍÍÍͼ" GOSUB pal COLOR 15 CALL msgFrame(23, 20, 55, 26) 'These lines form the menu CALL center("1. Begin game ", 21) CALL center("2. View Instructions", 22) CALL center("3. Options ", 23) CALL center("4. Demo ", 24) CALL center("5. Exit Program ", 25) DO SELECT CASE INKEY$ CASE "1": GOTO exitSub CASE "2" GOSUB instructions DO: LOOP WHILE INKEY$ = "" SCREEN 0: SCREEN 12 GOTO startTitleScreen CASE "3" GOSUB optionMenu SCREEN 0: SCREEN 12 GOTO startTitleScreen CASE "4" CALL demo GOTO startTitleScreen CASE "5": END END SELECT LOOP exitSub: SCREEN 0 'Reset the color palette to default SCREEN 12 EXIT SUB '--- Used for simplification in screen locating the big characters --- locat: y% = y% + 1 IF y% MOD 11 = 0 THEN y% = 6 x% = x% + 8 END IF LOCATE y%, x% RETURN '--- Performs the task of fading the characters in to yellow for c% --- pal: IF INKEY$ = CHR$(27) THEN fast% = -1 IF fast% = 0 THEN FOR i% = 1 TO 30 PALETTE c%, i% * 256 + i% * 2 FOR t = 1 TO processor / 3: NEXT t NEXT i% ELSE PALETTE c%, 30 * 256 + 60 END IF RETURN '--- Increments c% and changes the screen color --- setPal: c% = c% + 1 PALETTE c%, 0 COLOR c% RETURN '--- Draws the spiral on the screen --- drawSpiral: n$ = "bu5r5d10l10u10r5bd5" FOR s% = 2 TO 250 STEP 1.5 a% = a% + 5: IF a% >= 360 THEN a% = 0 DRAW "c0bm320,240s" + STR$(s% - 1) + "ta" + STR$(a% - 5) + "X" + VARPTR$(n$) DRAW "c9bm320,240s" + STR$(s%) + "ta" + STR$(a%) + "X" + VARPTR$(n$) NEXT s% RETURN '--- Displays the instructions --- '--- This is a local sub because it does not need to be accessed --- '--- gloabally --- instructions: CLS GOSUB drawSpiral i$(1) = "ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»" i$(2) = "º Controls : º" i$(3) = "º þ Up arrow - Move up º" i$(4) = "º þ Down arrow - Move down º" i$(5) = "º þ Left arrow - Move left º" i$(6) = "º þ Right arrow - Move right º" i$(7) = "º þ ESCaspe - Self Destruct º" i$(8) = "º þ SpaceBar - Fire primary weapon º" i$(9) = "º þ P - Load photon charge º" i$(10) = "º þ L - Load laser º" i$(11) = "º þ H - Fire homing missle º" i$(12) = "º þ M - Fire mega missle º" i$(13) = "º þ C - Toggle Cloak on/off º" i$(14) = "º þ S - Toggle Shields on/off º" i$(15) = "ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ" FOR d% = 1 TO 15 hLoc% = d% + 2 CALL center(i$(d%), hLoc%) NEXT d% RETURN optionMenu: CLS GOSUB drawSpiral COLOR 15 CALL msgFrame(20, 6, 59, 20) CALL center("Set Game Speed", 8) CALL center("ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ", 9) CALL center("6. Slow ", 11) CALL center("7. Medium ", 12) CALL center("8. Fast ", 13) CALL center("9. *Very* Fast ", 14) DO: any$ = INKEY$: LOOP UNTIL any$ <> "" IF any$ = "6" THEN processor = 2000 IF any$ = "7" THEN processor = 1000 IF any$ = "8" THEN processor = 500 IF any$ = "9" THEN processor = 1 CALL msgFrame(20, 6, 59, 20) CALL center("Status Bar", 8) CALL center("1. Graphical", 14) CALL center("2. Text ", 15) DO: any$ = INKEY$: LOOP UNTIL any$ <> "" IF VAL(any$) = 1 THEN barMode = "G" IF VAL(any$) = 2 THEN barMode = "T" OPEN "boxboss.dat" FOR OUTPUT AS #1 'Save option settings PRINT #1, processor PRINT #1, barMode CLOSE #1 CLS RETURN END SUB SUB tractorShot (tractor AS shotType, px%, py%, bx%) IF tractor.enabled = -1 THEN DO UNTIL px% >= bx% - 100 lx% = px% px% = px% + 5 CALL initPlayer(lx%, py%, px%, py%) LOOP tractor.enabled = 0 PALETTE 14, 63 * 256 + 63 END IF END SUB