Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

721 lines
24 KiB

  1. '
  2. ' Q B a s i c N i b b l e s
  3. '
  4. ' Copyright (C) Microsoft Corporation 1990
  5. '
  6. ' Nibbles is a game for one or two players. Navigate your snakes
  7. ' around the game board trying to eat up numbers while avoiding
  8. ' running into walls or other snakes. The more numbers you eat up,
  9. ' the more points you gain and the longer your snake becomes.
  10. '
  11. ' To run this game, press Shift+F5.
  12. '
  13. ' To exit QBasic, press Alt, F, X.
  14. '
  15. ' To get help on a BASIC keyword, move the cursor to the keyword and press
  16. ' F1 or click the right mouse button.
  17. '
  18. 'Set default data type to integer for faster game play
  19. DEFINT A-Z
  20. 'User-defined TYPEs
  21. TYPE snakeBody
  22. row AS INTEGER
  23. col AS INTEGER
  24. END TYPE
  25. 'This type defines the player's snake
  26. TYPE snaketype
  27. head AS INTEGER
  28. length AS INTEGER
  29. row AS INTEGER
  30. col AS INTEGER
  31. direction AS INTEGER
  32. lives AS INTEGER
  33. score AS INTEGER
  34. scolor AS INTEGER
  35. alive AS INTEGER
  36. END TYPE
  37. 'This type is used to represent the playing screen in memory
  38. 'It is used to simulate graphics in text mode, and has some interesting,
  39. 'and slightly advanced methods to increasing the speed of operation.
  40. 'Instead of the normal 80x25 text graphics using chr$(219) "�", we will be
  41. 'using chr$(220)"�" and chr$(223) "�" and chr$(219) "�" to mimic an 80x50
  42. 'pixel screen.
  43. 'Check out sub-programs SET and POINTISTHERE to see how this is implemented
  44. 'feel free to copy these (as well as arenaType and the DIM ARENA stmt and the
  45. 'initialization code in the DrawScreen subprogram) and use them in your own
  46. 'programs
  47. TYPE arenaType
  48. realRow AS INTEGER 'Maps the 80x50 point into the real 80x25
  49. acolor AS INTEGER 'Stores the current color of the point
  50. sister AS INTEGER 'Each char has 2 points in it. .SISTER is
  51. END TYPE '-1 if sister point is above, +1 if below
  52. 'Sub Declarations
  53. DECLARE SUB SpacePause (text$)
  54. DECLARE SUB PrintScore (NumPlayers%, score1%, score2%, lives1%, lives2%)
  55. DECLARE SUB Intro ()
  56. DECLARE SUB GetInputs (NumPlayers, speed, diff$, monitor$)
  57. DECLARE SUB DrawScreen ()
  58. DECLARE SUB PlayNibbles (NumPlayers, speed, diff$)
  59. DECLARE SUB Set (row, col, acolor)
  60. DECLARE SUB Center (row, text$)
  61. DECLARE SUB DoIntro ()
  62. DECLARE SUB Initialize ()
  63. DECLARE SUB SparklePause ()
  64. DECLARE SUB Level (WhatToDO, sammy() AS snaketype)
  65. DECLARE SUB InitColors ()
  66. DECLARE SUB EraseSnake (snake() AS ANY, snakeBod() AS ANY, snakeNum%)
  67. DECLARE FUNCTION StillWantsToPlay ()
  68. DECLARE FUNCTION PointIsThere (row, col, backColor)
  69. 'Constants
  70. CONST TRUE = -1
  71. CONST FALSE = NOT TRUE
  72. CONST MAXSNAKELENGTH = 1000
  73. CONST STARTOVER = 1 ' Parameters to 'Level' SUB
  74. CONST SAMELEVEL = 2
  75. CONST NEXTLEVEL = 3
  76. 'Global Variables
  77. DIM SHARED arena(1 TO 50, 1 TO 80) AS arenaType
  78. DIM SHARED curLevel, colorTable(10)
  79. RANDOMIZE TIMER
  80. GOSUB ClearKeyLocks
  81. Intro
  82. GetInputs NumPlayers, speed, diff$, monitor$
  83. GOSUB SetColors
  84. DrawScreen
  85. DO
  86. PlayNibbles NumPlayers, speed, diff$
  87. LOOP WHILE StillWantsToPlay
  88. GOSUB RestoreKeyLocks
  89. COLOR 15, 0
  90. CLS
  91. END
  92. ClearKeyLocks:
  93. DEF SEG = 0 ' Turn off CapLock, NumLock and ScrollLock
  94. KeyFlags = PEEK(1047)
  95. POKE 1047, &H0
  96. DEF SEG
  97. RETURN
  98. RestoreKeyLocks:
  99. DEF SEG = 0 ' Restore CapLock, NumLock and ScrollLock states
  100. POKE 1047, KeyFlags
  101. DEF SEG
  102. RETURN
  103. SetColors:
  104. IF monitor$ = "M" THEN
  105. RESTORE mono
  106. ELSE
  107. RESTORE normal
  108. END IF
  109. FOR a = 1 TO 6
  110. READ colorTable(a)
  111. NEXT a
  112. RETURN
  113. 'snake1 snake2 Walls Background Dialogs-Fore Back
  114. mono: DATA 15, 7, 7, 0, 15, 0
  115. normal: DATA 14, 13, 12, 1, 15, 4
  116. END
  117. 'Center:
  118. ' Centers text on given row
  119. SUB Center (row, text$)
  120. LOCATE row, 41 - LEN(text$) / 2
  121. PRINT text$;
  122. END SUB
  123. 'DrawScreen:
  124. ' Draws playing field
  125. SUB DrawScreen
  126. 'initialize screen
  127. VIEW PRINT
  128. COLOR colorTable(1), colorTable(4)
  129. CLS
  130. 'Print title & message
  131. Center 1, "Nibbles!"
  132. Center 11, "Initializing Playing Field..."
  133. 'Initialize arena array
  134. FOR row = 1 TO 50
  135. FOR col = 1 TO 80
  136. arena(row, col).realRow = INT((row + 1) / 2)
  137. arena(row, col).sister = (row MOD 2) * 2 - 1
  138. NEXT col
  139. NEXT row
  140. END SUB
  141. 'EraseSnake:
  142. ' Erases snake to facilitate moving through playing field
  143. SUB EraseSnake (snake() AS snaketype, snakeBod() AS snakeBody, snakeNum)
  144. FOR c = 0 TO 9
  145. FOR b = snake(snakeNum).length - c TO 0 STEP -10
  146. tail = (snake(snakeNum).head + MAXSNAKELENGTH - b) MOD MAXSNAKELENGTH
  147. Set snakeBod(tail, snakeNum).row, snakeBod(tail, snakeNum).col, colorTable(4)
  148. NEXT b
  149. NEXT c
  150. END SUB
  151. 'GetInputs:
  152. ' Gets player inputs
  153. SUB GetInputs (NumPlayers, speed, diff$, monitor$)
  154. COLOR 7, 0
  155. CLS
  156. DO
  157. LOCATE 5, 47: PRINT SPACE$(34);
  158. LOCATE 5, 20
  159. INPUT "How many players (1 or 2)"; num$
  160. LOOP UNTIL VAL(num$) = 1 OR VAL(num$) = 2
  161. NumPlayers = VAL(num$)
  162. LOCATE 8, 21: PRINT "Skill level (1 to 100)"
  163. LOCATE 9, 22: PRINT "1 = Novice"
  164. LOCATE 10, 22: PRINT "90 = Expert"
  165. LOCATE 11, 22: PRINT "100 = Twiddle Fingers"
  166. LOCATE 12, 15: PRINT "(Computer speed may affect your skill level)"
  167. DO
  168. LOCATE 8, 44: PRINT SPACE$(35);
  169. LOCATE 8, 43
  170. INPUT gamespeed$
  171. LOOP UNTIL VAL(gamespeed$) >= 1 AND VAL(gamespeed$) <= 100
  172. speed = VAL(gamespeed$)
  173. speed = (100 - speed) * 2 + 1
  174. DO
  175. LOCATE 15, 56: PRINT SPACE$(25);
  176. LOCATE 15, 15
  177. INPUT "Increase game speed during play (Y or N)"; diff$
  178. diff$ = UCASE$(diff$)
  179. LOOP UNTIL diff$ = "Y" OR diff$ = "N"
  180. DO
  181. LOCATE 17, 46: PRINT SPACE$(34);
  182. LOCATE 17, 17
  183. INPUT "Monochrome or color monitor (M or C)"; monitor$
  184. monitor$ = UCASE$(monitor$)
  185. LOOP UNTIL monitor$ = "M" OR monitor$ = "C"
  186. startTime# = TIMER ' Calculate speed of system
  187. FOR i# = 1 TO 1000: NEXT i# ' and do some compensation
  188. stopTime# = TIMER
  189. speed = speed * .5 / (stopTime# - startTime#)
  190. END SUB
  191. 'InitColors:
  192. 'Initializes playing field colors
  193. SUB InitColors
  194. FOR row = 1 TO 50
  195. FOR col = 1 TO 80
  196. arena(row, col).acolor = colorTable(4)
  197. NEXT col
  198. NEXT row
  199. CLS
  200. 'Set (turn on) pixels for screen border
  201. FOR col = 1 TO 80
  202. Set 3, col, colorTable(3)
  203. Set 50, col, colorTable(3)
  204. NEXT col
  205. FOR row = 4 TO 49
  206. Set row, 1, colorTable(3)
  207. Set row, 80, colorTable(3)
  208. NEXT row
  209. END SUB
  210. 'Intro:
  211. ' Displays game introduction
  212. SUB Intro
  213. SCREEN 0
  214. WIDTH 80, 25
  215. COLOR 15, 0
  216. CLS
  217. Center 4, "Q B a s i c N i b b l e s"
  218. COLOR 7
  219. Center 6, "Copyright (C) Microsoft Corporation 1990"
  220. Center 8, "Nibbles is a game for one or two players. Navigate your snakes"
  221. Center 9, "around the game board trying to eat up numbers while avoiding"
  222. Center 10, "running into walls or other snakes. The more numbers you eat up,"
  223. Center 11, "the more points you gain and the longer your snake becomes."
  224. Center 13, " Game Controls "
  225. Center 15, " General Player 1 Player 2 "
  226. Center 16, " (Up) (Up) "
  227. Center 17, "P - Pause " + CHR$(24) + " W "
  228. Center 18, " (Left) " + CHR$(27) + " " + CHR$(26) + " (Right) (Left) A D (Right) "
  229. Center 19, " " + CHR$(25) + " S "
  230. Center 20, " (Down) (Down) "
  231. Center 24, "Press any key to continue"
  232. PLAY "MBT160O1L8CDEDCDL4ECC"
  233. SparklePause
  234. END SUB
  235. 'Level:
  236. 'Sets game level
  237. SUB Level (WhatToDO, sammy() AS snaketype) STATIC
  238. SELECT CASE (WhatToDO)
  239. CASE STARTOVER
  240. curLevel = 1
  241. CASE NEXTLEVEL
  242. curLevel = curLevel + 1
  243. END SELECT
  244. sammy(1).head = 1 'Initialize Snakes
  245. sammy(1).length = 2
  246. sammy(1).alive = TRUE
  247. sammy(2).head = 1
  248. sammy(2).length = 2
  249. sammy(2).alive = TRUE
  250. InitColors
  251. SELECT CASE curLevel
  252. CASE 1
  253. sammy(1).row = 25: sammy(2).row = 25
  254. sammy(1).col = 50: sammy(2).col = 30
  255. sammy(1).direction = 4: sammy(2).direction = 3
  256. CASE 2
  257. FOR i = 20 TO 60
  258. Set 25, i, colorTable(3)
  259. NEXT i
  260. sammy(1).row = 7: sammy(2).row = 43
  261. sammy(1).col = 60: sammy(2).col = 20
  262. sammy(1).direction = 3: sammy(2).direction = 4
  263. CASE 3
  264. FOR i = 10 TO 40
  265. Set i, 20, colorTable(3)
  266. Set i, 60, colorTable(3)
  267. NEXT i
  268. sammy(1).row = 25: sammy(2).row = 25
  269. sammy(1).col = 50: sammy(2).col = 30
  270. sammy(1).direction = 1: sammy(2).direction = 2
  271. CASE 4
  272. FOR i = 4 TO 30
  273. Set i, 20, colorTable(3)
  274. Set 53 - i, 60, colorTable(3)
  275. NEXT i
  276. FOR i = 2 TO 40
  277. Set 38, i, colorTable(3)
  278. Set 15, 81 - i, colorTable(3)
  279. NEXT i
  280. sammy(1).row = 7: sammy(2).row = 43
  281. sammy(1).col = 60: sammy(2).col = 20
  282. sammy(1).direction = 3: sammy(2).direction = 4
  283. CASE 5
  284. FOR i = 13 TO 39
  285. Set i, 21, colorTable(3)
  286. Set i, 59, colorTable(3)
  287. NEXT i
  288. FOR i = 23 TO 57
  289. Set 11, i, colorTable(3)
  290. Set 41, i, colorTable(3)
  291. NEXT i
  292. sammy(1).row = 25: sammy(2).row = 25
  293. sammy(1).col = 50: sammy(2).col = 30
  294. sammy(1).direction = 1: sammy(2).direction = 2
  295. CASE 6
  296. FOR i = 4 TO 49
  297. IF i > 30 OR i < 23 THEN
  298. Set i, 10, colorTable(3)
  299. Set i, 20, colorTable(3)
  300. Set i, 30, colorTable(3)
  301. Set i, 40, colorTable(3)
  302. Set i, 50, colorTable(3)
  303. Set i, 60, colorTable(3)
  304. Set i, 70, colorTable(3)
  305. END IF
  306. NEXT i
  307. sammy(1).row = 7: sammy(2).row = 43
  308. sammy(1).col = 65: sammy(2).col = 15
  309. sammy(1).direction = 2: sammy(2).direction = 1
  310. CASE 7
  311. FOR i = 4 TO 49 STEP 2
  312. Set i, 40, colorTable(3)
  313. NEXT i
  314. sammy(1).row = 7: sammy(2).row = 43
  315. sammy(1).col = 65: sammy(2).col = 15
  316. sammy(1).direction = 2: sammy(2).direction = 1
  317. CASE 8
  318. FOR i = 4 TO 40
  319. Set i, 10, colorTable(3)
  320. Set 53 - i, 20, colorTable(3)
  321. Set i, 30, colorTable(3)
  322. Set 53 - i, 40, colorTable(3)
  323. Set i, 50, colorTable(3)
  324. Set 53 - i, 60, colorTable(3)
  325. Set i, 70, colorTable(3)
  326. NEXT i
  327. sammy(1).row = 7: sammy(2).row = 43
  328. sammy(1).col = 65: sammy(2).col = 15
  329. sammy(1).direction = 2: sammy(2).direction = 1
  330. CASE 9
  331. FOR i = 6 TO 47
  332. Set i, i, colorTable(3)
  333. Set i, i + 28, colorTable(3)
  334. NEXT i
  335. sammy(1).row = 40: sammy(2).row = 15
  336. sammy(1).col = 75: sammy(2).col = 5
  337. sammy(1).direction = 1: sammy(2).direction = 2
  338. CASE ELSE
  339. FOR i = 4 TO 49 STEP 2
  340. Set i, 10, colorTable(3)
  341. Set i + 1, 20, colorTable(3)
  342. Set i, 30, colorTable(3)
  343. Set i + 1, 40, colorTable(3)
  344. Set i, 50, colorTable(3)
  345. Set i + 1, 60, colorTable(3)
  346. Set i, 70, colorTable(3)
  347. NEXT i
  348. sammy(1).row = 7: sammy(2).row = 43
  349. sammy(1).col = 65: sammy(2).col = 15
  350. sammy(1).direction = 2: sammy(2).direction = 1
  351. END SELECT
  352. END SUB
  353. 'PlayNibbles:
  354. ' Main routine that controls game play
  355. SUB PlayNibbles (NumPlayers, speed, diff$)
  356. 'Initialize Snakes
  357. DIM sammyBody(MAXSNAKELENGTH - 1, 1 TO 2) AS snakeBody
  358. DIM sammy(1 TO 2) AS snaketype
  359. sammy(1).lives = 5
  360. sammy(1).score = 0
  361. sammy(1).scolor = colorTable(1)
  362. sammy(2).lives = 5
  363. sammy(2).score = 0
  364. sammy(2).scolor = colorTable(2)
  365. Level STARTOVER, sammy()
  366. startRow1 = sammy(1).row: startCol1 = sammy(1).col
  367. startRow2 = sammy(2).row: startCol2 = sammy(2).col
  368. curSpeed = speed
  369. 'play Nibbles until finished
  370. SpacePause " Level" + STR$(curLevel) + ", Push Space"
  371. gameOver = FALSE
  372. DO
  373. IF NumPlayers = 1 THEN
  374. sammy(2).row = 0
  375. END IF
  376. number = 1 'Current number that snakes are trying to run into
  377. nonum = TRUE 'nonum = TRUE if a number is not on the screen
  378. playerDied = FALSE
  379. PrintScore NumPlayers, sammy(1).score, sammy(2).score, sammy(1).lives, sammy(2).lives
  380. PLAY "T160O1>L20CDEDCDL10ECC"
  381. DO
  382. 'Print number if no number exists
  383. IF nonum = TRUE THEN
  384. DO
  385. numberRow = INT(RND(1) * 47 + 3)
  386. NumberCol = INT(RND(1) * 78 + 2)
  387. sisterRow = numberRow + arena(numberRow, NumberCol).sister
  388. LOOP UNTIL NOT PointIsThere(numberRow, NumberCol, colorTable(4)) AND NOT PointIsThere(sisterRow, NumberCol, colorTable(4))
  389. numberRow = arena(numberRow, NumberCol).realRow
  390. nonum = FALSE
  391. COLOR colorTable(1), colorTable(4)
  392. LOCATE numberRow, NumberCol
  393. PRINT RIGHT$(STR$(number), 1);
  394. count = 0
  395. END IF
  396. 'Delay game
  397. FOR a# = 1 TO curSpeed: NEXT a#
  398. 'Get keyboard input & Change direction accordingly
  399. kbd$ = INKEY$
  400. SELECT CASE kbd$
  401. CASE "w", "W": IF sammy(2).direction <> 2 THEN sammy(2).direction = 1
  402. CASE "s", "S": IF sammy(2).direction <> 1 THEN sammy(2).direction = 2
  403. CASE "a", "A": IF sammy(2).direction <> 4 THEN sammy(2).direction = 3
  404. CASE "d", "D": IF sammy(2).direction <> 3 THEN sammy(2).direction = 4
  405. CASE CHR$(0) + "H": IF sammy(1).direction <> 2 THEN sammy(1).direction = 1
  406. CASE CHR$(0) + "P": IF sammy(1).direction <> 1 THEN sammy(1).direction = 2
  407. CASE CHR$(0) + "K": IF sammy(1).direction <> 4 THEN sammy(1).direction = 3
  408. CASE CHR$(0) + "M": IF sammy(1).direction <> 3 THEN sammy(1).direction = 4
  409. CASE "p", "P": SpacePause " Game Paused ... Push Space "
  410. CASE ELSE
  411. END SELECT
  412. FOR a = 1 TO NumPlayers
  413. 'Move Snake
  414. SELECT CASE sammy(a).direction
  415. CASE 1: sammy(a).row = sammy(a).row - 1
  416. CASE 2: sammy(a).row = sammy(a).row + 1
  417. CASE 3: sammy(a).col = sammy(a).col - 1
  418. CASE 4: sammy(a).col = sammy(a).col + 1
  419. END SELECT
  420. 'If snake hits number, respond accordingly
  421. IF numberRow = INT((sammy(a).row + 1) / 2) AND NumberCol = sammy(a).col THEN
  422. PLAY "MBO0L16>CCCE"
  423. IF sammy(a).length < (MAXSNAKELENGTH - 30) THEN
  424. sammy(a).length = sammy(a).length + number * 4
  425. END IF
  426. sammy(a).score = sammy(a).score + number
  427. PrintScore NumPlayers, sammy(1).score, sammy(2).score, sammy(1).lives, sammy(2).lives
  428. number = number + 1
  429. IF number = 10 THEN
  430. EraseSnake sammy(), sammyBody(), 1
  431. EraseSnake sammy(), sammyBody(), 2
  432. LOCATE numberRow, NumberCol: PRINT " "
  433. Level NEXTLEVEL, sammy()
  434. PrintScore NumPlayers, sammy(1).score, sammy(2).score, sammy(1).lives, sammy(2).lives
  435. SpacePause " Level" + STR$(curLevel) + ", Push Space"
  436. IF NumPlayers = 1 THEN sammy(2).row = 0
  437. number = 1
  438. IF diff$ = "P" THEN speed = speed - 10: curSpeed = speed
  439. END IF
  440. nonum = TRUE
  441. IF curSpeed < 1 THEN curSpeed = 1
  442. END IF
  443. NEXT a
  444. FOR a = 1 TO NumPlayers
  445. 'If player runs into any point, or the head of the other snake, it dies.
  446. IF PointIsThere(sammy(a).row, sammy(a).col, colorTable(4)) OR (sammy(1).row = sammy(2).row AND sammy(1).col = sammy(2).col) THEN
  447. PLAY "MBO0L32EFGEFDC"
  448. COLOR , colorTable(4)
  449. LOCATE numberRow, NumberCol
  450. PRINT " "
  451. playerDied = TRUE
  452. sammy(a).alive = FALSE
  453. sammy(a).lives = sammy(a).lives - 1
  454. 'Otherwise, move the snake, and erase the tail
  455. ELSE
  456. sammy(a).head = (sammy(a).head + 1) MOD MAXSNAKELENGTH
  457. sammyBody(sammy(a).head, a).row = sammy(a).row
  458. sammyBody(sammy(a).head, a).col = sammy(a).col
  459. tail = (sammy(a).head + MAXSNAKELENGTH - sammy(a).length) MOD MAXSNAKELENGTH
  460. Set sammyBody(tail, a).row, sammyBody(tail, a).col, colorTable(4)
  461. sammyBody(tail, a).row = 0
  462. Set sammy(a).row, sammy(a).col, sammy(a).scolor
  463. END IF
  464. NEXT a
  465. LOOP UNTIL playerDied
  466. curSpeed = speed ' reset speed to initial value
  467. FOR a = 1 TO NumPlayers
  468. EraseSnake sammy(), sammyBody(), a
  469. 'If dead, then erase snake in really cool way
  470. IF sammy(a).alive = FALSE THEN
  471. 'Update score
  472. sammy(a).score = sammy(a).score - 10
  473. PrintScore NumPlayers, sammy(1).score, sammy(2).score, sammy(1).lives, sammy(2).lives
  474. IF a = 1 THEN
  475. SpacePause " Sammy Dies! Push Space! --->"
  476. ELSE
  477. SpacePause " <---- Jake Dies! Push Space "
  478. END IF
  479. END IF
  480. NEXT a
  481. Level SAMELEVEL, sammy()
  482. PrintScore NumPlayers, sammy(1).score, sammy(2).score, sammy(1).lives, sammy(2).lives
  483. 'Play next round, until either of snake's lives have run out.
  484. LOOP UNTIL sammy(1).lives = 0 OR sammy(2).lives = 0
  485. END SUB
  486. 'PointIsThere:
  487. ' Checks the global arena array to see if the boolean flag is set
  488. FUNCTION PointIsThere (row, col, acolor)
  489. IF row <> 0 THEN
  490. IF arena(row, col).acolor <> acolor THEN
  491. PointIsThere = TRUE
  492. ELSE
  493. PointIsThere = FALSE
  494. END IF
  495. END IF
  496. END FUNCTION
  497. 'PrintScore:
  498. ' Prints players scores and number of lives remaining
  499. SUB PrintScore (NumPlayers, score1, score2, lives1, lives2)
  500. COLOR 15, colorTable(4)
  501. IF NumPlayers = 2 THEN
  502. LOCATE 1, 1
  503. PRINT USING "#,###,#00 Lives: # <--JAKE"; score2; lives2
  504. END IF
  505. LOCATE 1, 49
  506. PRINT USING "SAMMY--> Lives: # #,###,#00"; lives1; score1
  507. END SUB
  508. 'Set:
  509. ' Sets row and column on playing field to given color to facilitate moving
  510. ' of snakes around the field.
  511. SUB Set (row, col, acolor)
  512. IF row <> 0 THEN
  513. arena(row, col).acolor = acolor 'assign color to arena
  514. realRow = arena(row, col).realRow 'Get real row of pixel
  515. topFlag = arena(row, col).sister + 1 / 2 'Deduce whether pixel
  516. 'is on top�, or bottom�
  517. sisterRow = row + arena(row, col).sister 'Get arena row of sister
  518. sisterColor = arena(sisterRow, col).acolor 'Determine sister's color
  519. LOCATE realRow, col
  520. IF acolor = sisterColor THEN 'If both points are same
  521. COLOR acolor, acolor 'Print chr$(219) "�"
  522. PRINT CHR$(219);
  523. ELSE
  524. IF topFlag THEN 'Since you cannot have
  525. IF acolor > 7 THEN 'bright backgrounds
  526. COLOR acolor, sisterColor 'determine best combo
  527. PRINT CHR$(223); 'to use.
  528. ELSE
  529. COLOR sisterColor, acolor
  530. PRINT CHR$(220);
  531. END IF
  532. ELSE
  533. IF acolor > 7 THEN
  534. COLOR acolor, sisterColor
  535. PRINT CHR$(220);
  536. ELSE
  537. COLOR sisterColor, acolor
  538. PRINT CHR$(223);
  539. END IF
  540. END IF
  541. END IF
  542. END IF
  543. END SUB
  544. 'SpacePause:
  545. ' Pauses game play and waits for space bar to be pressed before continuing
  546. SUB SpacePause (text$)
  547. COLOR colorTable(5), colorTable(6)
  548. Center 11, "���������������������������������"
  549. Center 12, "� " + LEFT$(text$ + SPACE$(29), 29) + " �"
  550. Center 13, "���������������������������������"
  551. WHILE INKEY$ <> "": WEND
  552. WHILE INKEY$ <> " ": WEND
  553. COLOR 15, colorTable(4)
  554. FOR i = 21 TO 26 ' Restore the screen background
  555. FOR j = 24 TO 56
  556. Set i, j, arena(i, j).acolor
  557. NEXT j
  558. NEXT i
  559. END SUB
  560. 'SparklePause:
  561. ' Creates flashing border for intro screen
  562. SUB SparklePause
  563. COLOR 4, 0
  564. a$ = "* * * * * * * * * * * * * * * * * "
  565. WHILE INKEY$ <> "": WEND 'Clear keyboard buffer
  566. WHILE INKEY$ = ""
  567. FOR a = 1 TO 5
  568. LOCATE 1, 1 'print horizontal sparkles
  569. PRINT MID$(a$, a, 80);
  570. LOCATE 22, 1
  571. PRINT MID$(a$, 6 - a, 80);
  572. FOR b = 2 TO 21 'Print Vertical sparkles
  573. c = (a + b) MOD 5
  574. IF c = 1 THEN
  575. LOCATE b, 80
  576. PRINT "*";
  577. LOCATE 23 - b, 1
  578. PRINT "*";
  579. ELSE
  580. LOCATE b, 80
  581. PRINT " ";
  582. LOCATE 23 - b, 1
  583. PRINT " ";
  584. END IF
  585. NEXT b
  586. NEXT a
  587. WEND
  588. END SUB
  589. 'StillWantsToPlay:
  590. ' Determines if users want to play game again.
  591. FUNCTION StillWantsToPlay
  592. COLOR colorTable(5), colorTable(6)
  593. Center 10, "���������������������������������"
  594. Center 11, "� G A M E O V E R �"
  595. Center 12, "� �"
  596. Center 13, "� Play Again? (Y/N) �"
  597. Center 14, "���������������������������������"
  598. WHILE INKEY$ <> "": WEND
  599. DO
  600. kbd$ = UCASE$(INKEY$)
  601. LOOP UNTIL kbd$ = "Y" OR kbd$ = "N"
  602. COLOR 15, colorTable(4)
  603. Center 10, " "
  604. Center 11, " "
  605. Center 12, " "
  606. Center 13, " "
  607. Center 14, " "
  608. IF kbd$ = "Y" THEN
  609. StillWantsToPlay = TRUE
  610. ELSE
  611. StillWantsToPlay = FALSE
  612. COLOR 7, 0
  613. CLS
  614. END IF
  615. END FUNCTION
  616.