1 ' Q B a s i c G o r i l l a s
3 ' Copyright (C) Microsoft Corporation 1990
5 ' Your mission is to hit your opponent with the exploding banana
6 ' by varying the angle and power of your throw, taking into account
7 ' wind speed, gravity, and the city skyline.
9 ' Speed of this game is determined by the constant SPEEDCONST. If the
10 ' program is too slow or too fast adjust the "CONST SPEEDCONST = 500" line
11 ' below. The larger the number the faster the game will go.
13 ' To run this game, press Shift+F5.
15 ' To exit QBasic, press Alt, F, X.
17 ' To get help on a BASIC keyword, move the cursor to the keyword and press
18 ' F1 or click the right mouse button.
21 'Set default data type to integer for faster game play
25 DECLARE SUB DoSun (Mouth)
26 DECLARE SUB SetScreen ()
27 DECLARE SUB EndGame ()
28 DECLARE SUB Center (Row, Text$)
30 DECLARE SUB SparklePause ()
31 DECLARE SUB GetInputs (Player1$, Player2$, NumGames)
32 DECLARE SUB PlayGame (Player1$, Player2$, NumGames)
33 DECLARE SUB DoExplosion (x#, y#)
34 DECLARE SUB MakeCityScape (BCoor() AS ANY)
35 DECLARE SUB PlaceGorillas (BCoor() AS ANY)
36 DECLARE SUB UpdateScores (Record(), PlayerNum, Results)
37 DECLARE SUB DrawGorilla (x, y, arms)
38 DECLARE SUB GorillaIntro (Player1$, Player2$)
40 DECLARE SUB VictoryDance (Player)
41 DECLARE SUB ClearGorillas ()
42 DECLARE SUB DrawBan (xc#, yc#, r, bc)
43 DECLARE FUNCTION Scl (n!)
44 DECLARE FUNCTION GetNum# (Row, Col)
45 DECLARE FUNCTION DoShot (PlayerNum, x, y)
46 DECLARE FUNCTION ExplodeGorilla (x#, y#)
47 DECLARE FUNCTION Getn# (Row, Col)
48 DECLARE FUNCTION PlotShot (StartX, StartY, Angle#, Velocity, PlayerNum)
49 DECLARE FUNCTION CalcDelay! ()
51 'Make all arrays Dynamic
61 CONST SPEEDCONST = 500
63 CONST FALSE = NOT TRUE
67 CONST WINDOWCOLOR = 14
69 CONST SUNHAPPY = FALSE
76 DIM SHARED GorillaX(1 TO 2) 'Location of the two gorillas
77 DIM SHARED GorillaY(1 TO 2)
78 DIM SHARED LastBuilding
81 DIM SHARED LBan&(x), RBan&(x), UBan&(x), DBan&(x) 'Graphical picture of banana
82 DIM SHARED GorD&(120) 'Graphical picture of Gorilla arms down
83 DIM SHARED GorL&(120) 'Gorilla left arm raised
84 DIM SHARED GorR&(120) 'Gorilla right arm raised
89 'Screen Mode Variables
95 'Screen Color Variables
96 DIM SHARED ExplosionColor
103 DIM SHARED MachSpeed AS SINGLE
105 DEF FnRan (x) = INT(RND(1) * x) + 1
106 DEF SEG = 0 ' Set NumLock to ON
107 KeyFlags = PEEK(1047)
108 IF (KeyFlags AND 32) = 0 THEN
109 POKE 1047, KeyFlags OR 32
115 GetInputs Name1$, Name2$, NumGames
116 GorillaIntro Name1$, Name2$
117 PlayGame Name1$, Name2$, NumGames
119 DEF SEG = 0 ' Restore NumLock state
127 DATA 327686, -252645316, 60
129 DATA 196618, -1057030081, 49344
131 DATA 196618, -1056980800, 63
133 DATA 327686, 1010580720, 240
137 DATA 458758,202116096,471604224,943208448,943208448,943208448,471604224,202116096,0
139 DATA 262153, -2134835200, -2134802239, -2130771968, -2130738945,8323072, 8323199, 4063232, 4063294
141 DATA 262153, 4063232, 4063294, 8323072, 8323199, -2130771968, -2130738945, -2134835200,-2134802239
143 DATA 458758, -1061109760, -522133504, 1886416896, 1886416896, 1886416896,-522133504,-1061109760,0
148 'This is a clever way to pick the best graphics mode available
149 ON ERROR GOTO ScreenModeError
152 ON ERROR GOTO PaletteError
153 IF Mode = 9 THEN PALETTE 4, 0 'Check for 64K EGA
156 MachSpeed = CalcDelay
163 REDIM LBan&(8), RBan&(8), UBan&(8), DBan&(8)
189 REDIM LBan&(2), RBan&(2), UBan&(2), DBan&(2)
190 REDIM GorL&(20), GorD&(20), GorR&(20)
205 MachSpeed = MachSpeed * 1.3
214 PRINT "Sorry, you must have CGA, EGA color, or VGA graphics to play GORILLA.BAS"
222 Mode = 1 '64K EGA cards will run in CGA mode.
227 ' Checks speed of the machine.
233 LOOP UNTIL TIMER - s! >= .5
239 ' Centers and prints a text string on a given row
241 ' Row - screen row number
242 ' Text$ - text to be printed
244 SUB Center (Row, Text$)
246 LOCATE Row, Col - (LEN(Text$) / 2 + .5)
251 ' Produces explosion when a shot is fired
253 ' X#, Y# - location of explosion
255 SUB DoExplosion (x#, y#)
257 PLAY "MBO0L32EFGEFDC"
258 Radius = ScrHeight / 50
259 IF Mode = 9 THEN Inc# = .5 ELSE Inc# = .41
260 FOR c# = 0 TO Radius STEP Inc#
261 CIRCLE (x#, y#), c#, ExplosionColor
263 FOR c# = Radius TO 0 STEP (-1 * Inc#)
264 CIRCLE (x#, y#), c#, BACKATTR
272 ' Controls banana shots by accepting player input and plotting
276 ' x, y - Player's gorilla position
278 FUNCTION DoShot (PlayerNum, x, y)
281 IF PlayerNum = 1 THEN
293 Angle# = GetNum#(2, LocateCol + 7)
297 Velocity = GetNum#(3, LocateCol + 10)
299 IF PlayerNum = 2 THEN
300 Angle# = 180 - Angle#
306 PRINT SPACE$(30 \ (80 \ MaxCol));
307 LOCATE i, (50 \ (80 \ MaxCol))
308 PRINT SPACE$(30 \ (80 \ MaxCol));
312 PlayerHit = PlotShot(x, y, Angle#, Velocity, PlayerNum)
313 IF PlayerHit = 0 THEN
317 IF PlayerHit = PlayerNum THEN PlayerNum = 3 - PlayerNum
318 VictoryDance PlayerNum
324 ' Draws the sun at the top of the screen.
326 ' Mouth - If TRUE draws "O" mouth else draws a smile mouth.
331 x = ScrWidth \ 2: y = Scl(25)
334 LINE (x - Scl(22), y - Scl(18))-(x + Scl(22), y + Scl(18)), BACKATTR, BF
338 CIRCLE (x, y), Scl(12), SUNATTR
339 PAINT (x, y), SUNATTR
342 LINE (x - Scl(20), y)-(x + Scl(20), y), SUNATTR
343 LINE (x, y - Scl(15))-(x, y + Scl(15)), SUNATTR
345 LINE (x - Scl(15), y - Scl(10))-(x + Scl(15), y + Scl(10)), SUNATTR
346 LINE (x - Scl(15), y + Scl(10))-(x + Scl(15), y - Scl(10)), SUNATTR
348 LINE (x - Scl(8), y - Scl(13))-(x + Scl(8), y + Scl(13)), SUNATTR
349 LINE (x - Scl(8), y + Scl(13))-(x + Scl(8), y - Scl(13)), SUNATTR
351 LINE (x - Scl(18), y - Scl(5))-(x + Scl(18), y + Scl(5)), SUNATTR
352 LINE (x - Scl(18), y + Scl(5))-(x + Scl(18), y - Scl(5)), SUNATTR
355 IF Mouth THEN 'draw "o" mouth
356 CIRCLE (x, y + Scl(5)), Scl(2.9), 0
357 PAINT (x, y + Scl(5)), 0, 0
359 CIRCLE (x, y), Scl(8), 0, (210 * pi# / 180), (330 * pi# / 180)
363 CIRCLE (x - 3, y - 2), 1, 0
364 CIRCLE (x + 3, y - 2), 1, 0
365 PSET (x - 3, y - 2), 0
366 PSET (x + 3, y - 2), 0
373 ' xc# - Horizontal Coordinate
374 ' yc# - Vertical Coordinate
375 ' r - rotation position (0-3). ( \_/ ) /-\
376 ' bc - if TRUE then DrawBan draws the banana ELSE it erases the banana
377 SUB DrawBan (xc#, yc#, r, bc)
381 IF bc THEN PUT (xc#, yc#), LBan&, PSET ELSE PUT (xc#, yc#), LBan&, XOR
383 IF bc THEN PUT (xc#, yc#), UBan&, PSET ELSE PUT (xc#, yc#), UBan&, XOR
385 IF bc THEN PUT (xc#, yc#), DBan&, PSET ELSE PUT (xc#, yc#), DBan&, XOR
387 IF bc THEN PUT (xc#, yc#), RBan&, PSET ELSE PUT (xc#, yc#), RBan&, XOR
393 ' Draws the Gorilla in either CGA or EGA mode
394 ' and saves the graphics data in an array.
396 ' x - x coordinate of gorilla
397 ' y - y coordinate of the gorilla
398 ' arms - either Left up, Right up, or both down
399 SUB DrawGorilla (x, y, arms)
400 DIM i AS SINGLE ' Local index must be single precision
403 LINE (x - Scl(4), y)-(x + Scl(2.9), y + Scl(6)), OBJECTCOLOR, BF
404 LINE (x - Scl(5), y + Scl(2))-(x + Scl(4), y + Scl(4)), OBJECTCOLOR, BF
407 LINE (x - Scl(3), y + Scl(2))-(x + Scl(2), y + Scl(2)), 0
412 PSET (x + i, y + 4), 0
413 PSET (x + i + 3, y + 4), 0
418 LINE (x - Scl(3), y + Scl(7))-(x + Scl(2), y + Scl(7)), OBJECTCOLOR
421 LINE (x - Scl(8), y + Scl(8))-(x + Scl(6.9), y + Scl(14)), OBJECTCOLOR, BF
422 LINE (x - Scl(6), y + Scl(15))-(x + Scl(4.9), y + Scl(20)), OBJECTCOLOR, BF
426 CIRCLE (x + Scl(i), y + Scl(25)), Scl(10), OBJECTCOLOR, 3 * pi# / 4, 9 * pi# / 8
427 CIRCLE (x + Scl(-6) + Scl(i - .1), y + Scl(25)), Scl(10), OBJECTCOLOR, 15 * pi# / 8, pi# / 4
431 CIRCLE (x - Scl(4.9), y + Scl(10)), Scl(4.9), 0, 3 * pi# / 2, 0
432 CIRCLE (x + Scl(4.9), y + Scl(10)), Scl(4.9), 0, pi#, 3 * pi# / 2
438 CIRCLE (x + Scl(i - .1), y + Scl(14)), Scl(9), OBJECTCOLOR, 3 * pi# / 4, 5 * pi# / 4
439 CIRCLE (x + Scl(4.9) + Scl(i), y + Scl(4)), Scl(9), OBJECTCOLOR, 7 * pi# / 4, pi# / 4
440 GET (x - Scl(15), y - Scl(1))-(x + Scl(14), y + Scl(28)), GorR&
443 CIRCLE (x + Scl(i - .1), y + Scl(4)), Scl(9), OBJECTCOLOR, 3 * pi# / 4, 5 * pi# / 4
444 CIRCLE (x + Scl(4.9) + Scl(i), y + Scl(14)), Scl(9), OBJECTCOLOR, 7 * pi# / 4, pi# / 4
445 GET (x - Scl(15), y - Scl(1))-(x + Scl(14), y + Scl(28)), GorL&
448 CIRCLE (x + Scl(i - .1), y + Scl(14)), Scl(9), OBJECTCOLOR, 3 * pi# / 4, 5 * pi# / 4
449 CIRCLE (x + Scl(4.9) + Scl(i), y + Scl(14)), Scl(9), OBJECTCOLOR, 7 * pi# / 4, pi# / 4
450 GET (x - Scl(15), y - Scl(1))-(x + Scl(14), y + Scl(28)), GorD&
456 ' Causes gorilla explosion when a direct hit occurs
458 ' X#, Y# - shot location
459 FUNCTION ExplodeGorilla (x#, y#)
462 SclX# = ScrWidth / 320
463 SclY# = ScrHeight / 200
464 IF x# < ScrWidth / 2 THEN PlayerHit = 1 ELSE PlayerHit = 2
465 PLAY "MBO0L16EFGEFDC"
467 FOR i = 1 TO 8 * SclX#
468 CIRCLE (GorillaX(PlayerHit) + 3.5 * SclX# + XAdj, GorillaY(PlayerHit) + 7 * SclY# + YAdj), i, ExplosionColor, , , -1.57
469 LINE (GorillaX(PlayerHit) + 7 * SclX#, GorillaY(PlayerHit) + 9 * SclY# - i)-(GorillaX(PlayerHit), GorillaY(PlayerHit) + 9 * SclY# - i), ExplosionColor
472 FOR i = 1 TO 16 * SclX#
473 IF i < (8 * SclX#) THEN CIRCLE (GorillaX(PlayerHit) + 3.5 * SclX# + XAdj, GorillaY(PlayerHit) + 7 * SclY# + YAdj), (8 * SclX# + 1) - i, BACKATTR, , , -1.57
474 CIRCLE (GorillaX(PlayerHit) + 3.5 * SclX# + XAdj, GorillaY(PlayerHit) + YAdj), i, i MOD 2 + 1, , , -1.57
477 FOR i = 24 * SclX# TO 1 STEP -1
478 CIRCLE (GorillaX(PlayerHit) + 3.5 * SclX# + XAdj, GorillaY(PlayerHit) + YAdj), i, BACKATTR, , , -1.57
483 ExplodeGorilla = PlayerHit
487 ' Gets user inputs at beginning of game
489 ' Player1$, Player2$ - player names
490 ' NumGames - number of games to play
491 SUB GetInputs (Player1$, Player2$, NumGames)
496 LINE INPUT "Name of Player 1 (Default = 'Player 1'): "; Player1$
497 IF Player1$ = "" THEN
498 Player1$ = "Player 1"
500 Player1$ = LEFT$(Player1$, 10)
504 LINE INPUT "Name of Player 2 (Default = 'Player 2'): "; Player2$
505 IF Player2$ = "" THEN
506 Player2$ = "Player 2"
508 Player2$ = LEFT$(Player2$, 10)
512 LOCATE 12, 56: PRINT SPACE$(25);
514 INPUT "Play to how many total points (Default = 3)"; game$
515 NumGames = VAL(LEFT$(game$, 2))
516 LOOP UNTIL NumGames > 0 AND LEN(game$) < 3 OR LEN(game$) = 0
517 IF NumGames = 0 THEN NumGames = 3
520 LOCATE 14, 53: PRINT SPACE$(28);
522 INPUT "Gravity in Meters/Sec (Earth = 9.8)"; grav$
523 gravity# = VAL(grav$)
524 LOOP UNTIL gravity# > 0 OR LEN(grav$) = 0
525 IF gravity# = 0 THEN gravity# = 9.8
529 ' Gets valid numeric input from user
531 ' Row, Col - location to echo input
532 FUNCTION GetNum# (Row, Col)
535 WHILE INKEY$ <> "": WEND 'Clear keyboard buffer
540 PRINT Result$; CHR$(95); " ";
545 Result$ = Result$ + Kbd$
547 IF INSTR(Result$, ".") = 0 THEN
548 Result$ = Result$ + Kbd$
551 IF VAL(Result$) > 360 THEN
557 IF LEN(Result$) > 0 THEN
558 Result$ = LEFT$(Result$, LEN(Result$) - 1)
561 IF LEN(Kbd$) > 0 THEN
570 GetNum# = VAL(Result$)
574 ' Displays gorillas on screen for the first time
575 ' allows the graphical data to be put into an array
577 ' Player1$, Player2$ - The names of the players
579 SUB GorillaIntro (Player1$, Player2$)
580 LOCATE 16, 34: PRINT "--------------"
581 LOCATE 18, 34: PRINT "V = View Intro"
582 LOCATE 19, 34: PRINT "P = Play Game"
583 LOCATE 21, 35: PRINT "Your Choice?"
600 IF Mode = 1 THEN Center 5, "Please wait while gorillas are drawn."
604 IF Mode = 9 THEN PALETTE OBJECTCOLOR, BackColor
606 DrawGorilla x, y, ARMSDOWN
608 DrawGorilla x, y, LEFTUP
610 DrawGorilla x, y, RIGHTUP
614 IF Mode = 9 THEN PALETTE OBJECTCOLOR, 46
616 IF UCASE$(Char$) = "V" THEN
617 Center 2, "Q B A S I C G O R I L L A S"
618 Center 5, " STARRING: "
619 P$ = Player1$ + " AND " + Player2$
622 PUT (x - 13, y), GorD&, PSET
623 PUT (x + 47, y), GorD&, PSET
626 PUT (x - 13, y), GorL&, PSET
627 PUT (x + 47, y), GorR&, PSET
628 PLAY "t120o1l16b9n0baan0bn0bn0baaan0b9n0baan0b"
631 PUT (x - 13, y), GorR&, PSET
632 PUT (x + 47, y), GorL&, PSET
633 PLAY "o2l16e-9n0e-d-d-n0e-n0e-n0e-d-d-d-n0e-9n0e-d-d-n0e-"
636 PUT (x - 13, y), GorL&, PSET
637 PUT (x + 47, y), GorR&, PSET
638 PLAY "o2l16g-9n0g-een0g-n0g-n0g-eeen0g-9n0g-een0g-"
641 PUT (x - 13, y), GorR&, PSET
642 PUT (x + 47, y), GorL&, PSET
643 PLAY "o2l16b9n0baan0g-n0g-n0g-eeen0o1b9n0baan0b"
647 PUT (x - 13, y), GorL&, PSET
648 PUT (x + 47, y), GorR&, PSET
649 PLAY "T160O0L32EFGEFDC"
651 PUT (x - 13, y), GorR&, PSET
652 PUT (x + 47, y), GorL&, PSET
653 PLAY "T160O0L32EFGEFDC"
660 ' Displays game introduction
669 Center 4, "Q B a s i c G O R I L L A S"
671 Center 6, "Copyright (C) Microsoft Corporation 1990"
672 Center 8, "Your mission is to hit your opponent with the exploding"
673 Center 9, "banana by varying the angle and power of your throw, taking"
674 Center 10, "into account wind speed, gravity, and the city skyline."
675 Center 11, "The wind speed is shown by a directional arrow at the bottom"
676 Center 12, "of the playing field, its length relative to its strength."
677 Center 24, "Press any key to continue"
679 PLAY "MBT160O1L8CDEDCDL4ECC"
681 IF Mode = 1 THEN MaxCol = 40
685 ' Creates random skyline for game
687 ' BCoor() - a user-defined type array which stores the coordinates of
688 ' the upper left corner of each building.
689 SUB MakeCityScape (BCoor() AS XYPoint)
693 'Set the sloping trend of the city scape. NewHt is new building height
696 CASE 1: NewHt = 15 'Upward slope
697 CASE 2: NewHt = 130 'Downward slope
698 CASE 3 TO 5: NewHt = 15 '"V" slope - most common
699 CASE 6: NewHt = 130 'Inverted "V" slope
703 BottomLine = 335 'Bottom of building
704 HtInc = 10 'Increase value for new height
705 DefBWidth = 37 'Default building height
706 RandomHeight = 120 'Random height difference
707 WWidth = 3 'Window width
708 WHeight = 6 'Window height
709 WDifV = 15 'Counter for window spacing - vertical
710 WDifh = 10 'Counter for window spacing - horizontal
714 NewHt = NewHt * 20 \ 35 'Adjust for CGA
728 NewHt = NewHt + HtInc
730 NewHt = NewHt - HtInc
732 IF x > ScrWidth \ 2 THEN
733 NewHt = NewHt - 2 * HtInc
735 NewHt = NewHt + 2 * HtInc
738 IF x > ScrWidth \ 2 THEN
739 NewHt = NewHt + 2 * HtInc
741 NewHt = NewHt - 2 * HtInc
745 'Set width of building and check to see if it would go off the screen
746 BWidth = FnRan(DefBWidth) + DefBWidth
747 IF x + BWidth > ScrWidth THEN BWidth = ScrWidth - x - 2
749 'Set height of building and check to see if it goes below screen
750 BHeight = FnRan(RandomHeight) + NewHt
751 IF BHeight < HtInc THEN BHeight = HtInc
753 'Check to see if Building is too high
754 IF BottomLine - BHeight <= MaxHeight + GHeight THEN BHeight = MaxHeight + GHeight - 5
756 'Set the coordinates of the building into the array
757 BCoor(CurBuilding).XCoor = x
758 BCoor(CurBuilding).YCoor = BottomLine - BHeight
760 IF Mode = 9 THEN BuildingColor = FnRan(3) + 4 ELSE BuildingColor = 2
762 'Draw the building, outline first, then filled
763 LINE (x - 1, BottomLine + 1)-(x + BWidth + 1, BottomLine - BHeight - 1), BACKGROUND, B
764 LINE (x, BottomLine)-(x + BWidth, BottomLine - BHeight), BuildingColor, BF
769 FOR i = BHeight - 3 TO 7 STEP -WDifV
771 WinColr = (FnRan(2) - 2) * -3
772 ELSEIF FnRan(4) = 1 THEN
775 WinColr = WINDOWCOLOR
777 LINE (c, BottomLine - i)-(c + WWidth, BottomLine - i + WHeight), WinColr, BF
780 LOOP UNTIL c >= x + BWidth - 3
784 CurBuilding = CurBuilding + 1
786 LOOP UNTIL x > ScrWidth - HtInc
788 LastBuilding = CurBuilding - 1
794 Wind = Wind + FnRan(10)
796 Wind = Wind - FnRan(10)
800 'Draw Wind speed arrow
802 WindLine = Wind * 3 * (ScrWidth \ 320)
803 LINE (ScrWidth \ 2, ScrHeight - 5)-(ScrWidth \ 2 + WindLine, ScrHeight - 5), ExplosionColor
804 IF Wind > 0 THEN ArrowDir = -2 ELSE ArrowDir = 2
805 LINE (ScrWidth / 2 + WindLine, ScrHeight - 5)-(ScrWidth / 2 + WindLine + ArrowDir, ScrHeight - 5 - 2), ExplosionColor
806 LINE (ScrWidth / 2 + WindLine, ScrHeight - 5)-(ScrWidth / 2 + WindLine + ArrowDir, ScrHeight - 5 + 2), ExplosionColor
811 ' PUTs the Gorillas on top of the buildings. Must have drawn
814 ' BCoor() - user-defined TYPE array which stores upper left coordinates
816 SUB PlaceGorillas (BCoor() AS XYPoint)
825 SclX# = ScrWidth / 320
826 SclY# = ScrHeight / 200
828 'Place gorillas on second or third building from edge
830 IF i = 1 THEN BNum = FnRan(2) + 1 ELSE BNum = LastBuilding - FnRan(2)
832 BWidth = BCoor(BNum + 1).XCoor - BCoor(BNum).XCoor
833 GorillaX(i) = BCoor(BNum).XCoor + BWidth / 2 - XAdj
834 GorillaY(i) = BCoor(BNum).YCoor - YAdj
835 PUT (GorillaX(i), GorillaY(i)), GorD&, PSET
841 ' Main game play routine
843 ' Player1$, Player2$ - player names
844 ' NumGames - number of games to play
845 SUB PlayGame (Player1$, Player2$, NumGames)
846 DIM BCoor(0 TO 30) AS XYPoint
847 DIM TotalWins(1 TO 2)
851 FOR i = 1 TO NumGames
855 CALL MakeCityScape(BCoor())
856 CALL PlaceGorillas(BCoor())
863 LOCATE 1, (MaxCol - 1 - LEN(Player2$))
865 Center 23, LTRIM$(STR$(TotalWins(1))) + ">Score<" + LTRIM$(STR$(TotalWins(2)))
866 Tosser = J + 1: Tossee = 3 - J
868 'Plot the shot. Hit is true if Gorilla gets hit.
869 Hit = DoShot(Tosser, GorillaX(Tosser), GorillaY(Tosser))
871 'Reset the sun, if it got hit
872 IF SunHit THEN DoSun SUNHAPPY
874 IF Hit = TRUE THEN CALL UpdateScores(TotalWins(), Tosser, Hit)
885 Center 8, "GAME OVER!"
887 LOCATE 11, 30: PRINT Player1$; TAB(50); TotalWins(1)
888 LOCATE 12, 30: PRINT Player2$; TAB(50); TotalWins(2)
889 Center 24, "Press any key to continue"
896 ' Plots banana shot across the screen
898 ' StartX, StartY - starting shot location
900 ' Velocity - shot velocity
901 ' PlayerNum - the banana thrower
902 FUNCTION PlotShot (StartX, StartY, Angle#, Velocity, PlayerNum)
904 Angle# = Angle# / 180 * pi# 'Convert degree angle to radians
907 InitXVel# = COS(Angle#) * Velocity
908 InitYVel# = SIN(Angle#) * Velocity
914 IF PlayerNum = 1 THEN
915 PUT (StartX, StartY), GorL&, PSET
917 PUT (StartX, StartY), GorR&, PSET
921 PLAY "MBo0L32A-L64CL16BL64A+"
925 PUT (StartX, StartY), GorD&, PSET
927 adjust = Scl(4) 'For scaling CGA
929 xedge = Scl(9) * (2 - PlayerNum) 'Find leading edge of banana for check
938 StartYPos = StartY - adjust - 3
940 IF PlayerNum = 2 THEN
941 StartXPos = StartXPos + Scl(25)
947 IF Velocity < 2 THEN 'Shot too slow - hit self
950 pointval = OBJECTCOLOR
953 DO WHILE (NOT Impact) AND OnScreen
957 'Erase old banana, if necessary
960 CALL DrawBan(oldx#, oldy#, oldrot, FALSE)
963 x# = StartXPos + (InitXVel# * t#) + (.5 * (Wind / 5) * t# ^ 2)
964 y# = StartYPos + ((-1 * (InitYVel# * t#)) + (.5 * gravity# * t# ^ 2)) * (ScrHeight / 350)
966 IF (x# >= ScrWidth - Scl(10)) OR (x# <= 3) OR (y# >= ScrHeight - 3) THEN
971 IF OnScreen AND y# > 0 THEN
975 LookX = Scl(8 * (2 - PlayerNum))
977 pointval = POINT(x# + LookX, y# + LookY)
980 IF ShotInSun = TRUE THEN
981 IF ABS(ScrWidth \ 2 - x#) > Scl(20) OR y# > SunHt THEN ShotInSun = FALSE
983 ELSEIF pointval = SUNATTR AND y# < SunHt THEN
984 IF NOT SunHit THEN DoSun SUNSHOCK
990 LookX = LookX + direction
991 LookY = LookY + Scl(6)
992 LOOP UNTIL Impact OR LookX <> Scl(4)
994 IF NOT ShotInSun AND NOT Impact THEN
996 rot = (t# * 10) MOD 4
997 CALL DrawBan(x#, y#, rot, TRUE)
1012 IF pointval <> OBJECTCOLOR AND Impact THEN
1013 CALL DoExplosion(x# + adjust, y# + adjust)
1014 ELSEIF pointval = OBJECTCOLOR THEN
1015 PlayerHit = ExplodeGorilla(x#, y#)
1018 PlotShot = PlayerHit
1023 ' pauses the program
1026 t2# = MachSpeed * t# / SPEEDCONST
1028 LOOP UNTIL TIMER - s# > t2#
1032 ' Pass the number in to scaling for cga. If the number is a decimal, then we
1033 ' want to scale down for cga or scale up for ega. This allows a full range
1034 ' of numbers to be generated for scaling.
1035 ' (i.e. for 3 to get scaled to 1, pass in 2.9)
1038 IF n! <> INT(n!) THEN
1039 IF Mode = 1 THEN n! = n! - 1
1042 Scl = CINT(n! / 2 + .1)
1050 ' Sets the appropriate color statements
1063 PALETTE 9, 63 'Display Color
1074 ' Creates flashing border for intro and game over screens
1078 A$ = "* * * * * * * * * * * * * * * * * "
1079 WHILE INKEY$ <> "": WEND 'Clear keyboard buffer
1083 LOCATE 1, 1 'print horizontal sparkles
1084 PRINT MID$(A$, A, 80);
1086 PRINT MID$(A$, 6 - A, 80);
1088 FOR b = 2 TO 21 'Print Vertical sparkles
1107 ' Updates players' scores
1109 ' Record - players' scores
1110 ' PlayerNum - player
1111 ' Results - results of player's shot
1112 SUB UpdateScores (Record(), PlayerNum, Results)
1113 IF Results = HITSELF THEN
1114 Record(ABS(PlayerNum - 3)) = Record(ABS(PlayerNum - 3)) + 1
1116 Record(PlayerNum) = Record(PlayerNum) + 1
1121 ' gorilla dances after he has eliminated his opponent
1123 ' Player - which gorilla is dancing
1124 SUB VictoryDance (Player)
1127 PUT (GorillaX(Player), GorillaY(Player)), GorL&, PSET
1128 PLAY "MFO0L32EFGEFDC"
1130 PUT (GorillaX(Player), GorillaY(Player)), GorR&, PSET
1131 PLAY "MFO0L32EFGEFDC"