' Q B a s i c N i b b l e s 3 ' ' Copyright (C) WendelSoft Corporation 1997-2001 ' ' Nibbles3 um jogo para um ou dois jogadores. Movam suas cobras ' ao redor da tela tentando comer nmeros enquanto evitam bater em ' muros ou outras cobras. Quanto mais nmeros voc come,mais pontos 'voc ganha e maior a sua cobra fica. possvel atravessar as paredes ' que contornam a tela,mas no as que aparecerem no meio. ' 'To run this game,press Shift+F5. ' 'To exit QBasic,press Alt,A,R. ' 'To get help on a BASIC keyword,move the cursor to the keyword and press 'F1 or click the right mouse button. ' DECLARE FUNCTION NewDir% (a%, b%) DECLARE SUB Intro () DECLARE SUB GetInputs (NumPlayers%, Speed%, difficulty%, diff$, monitor$) DECLARE SUB DrawScreen () DECLARE SUB PlayNibbles3 (NumPlayers%, Speed%, difficulty%, diff$) DECLARE SUB Center (row%, text$) DECLARE SUB EraseSnake (snake() AS ANY, snakeBod() AS ANY, snakeNum%) DECLARE SUB Set (row%, col%, acolor%) DECLARE SUB InitColors () DECLARE SUB SparklePause () DECLARE SUB Level (WhatToDO%, sammy() AS ANY) DECLARE SUB SpacePause (text$) DECLARE SUB PrintScore (NumPlayers%, score1%, score2%, lives1%, lives2%) DECLARE FUNCTION PointIsThere% (row%, col%, acolor%) DECLARE FUNCTION StillWantsToPlay% () DECLARE FUNCTION WantsToReconfig% () DEFINT A-Z '$DYNAMIC TYPE snakeBody row AS INTEGER col AS INTEGER END TYPE TYPE snaketype head AS INTEGER length AS INTEGER row AS INTEGER col AS INTEGER direction AS INTEGER lives AS INTEGER score AS INTEGER scolor AS INTEGER alive AS INTEGER END TYPE TYPE arenaType realRow AS INTEGER acolor AS INTEGER sister AS INTEGER END TYPE CONST TRUE = -1 CONST FALSE = NOT TRUE CONST MAXSNAKELENGTH = 1000 CONST STARTOVER = 1 CONST SAMELEVEL = 2 CONST NEXTLEVEL = 3 DIM SHARED arena(1 TO 50, 1 TO 80) AS arenaType DIM SHARED CurLevel, ColorTable(10), borda$, itSelf$ DIM SHARED kup1$, kdown1$, kleft1$, kright1$ DIM SHARED kup2$, kdown2$, kleft2$, kright2$ RANDOMIZE TIMER Start: GOSUB ClearKeyLocks Intro GetInputs NumPlayers, Speed, difficulty, diff$, monitor$ GOSUB SetColors DrawScreen CRt = FALSE DO IF CRt THEN IF WantsToReconfig GOTO Start PlayNibbles3 NumPlayers, Speed, difficulty, diff$ CRt = TRUE LOOP WHILE StillWantsToPlay GOSUB RestoreKeyLocks COLOR 7, 0 CLS SYSTEM ClearKeyLocks: DEF SEG = 0 KeyFlags = PEEK(1047) POKE 1047, &H0 DEF SEG RETURN RestoreKeyLocks: DEF SEG = 0 POKE 1047, KeyFlags DEF SEG RETURN SetColors: IF monitor$ = "P" THEN RESTORE mono ELSEIF monitor$ = "C" THEN RESTORE normal ELSE CLS Center 1, "Esquema de cores" DIM Cor(0 TO 15) AS STRING * 17 DIM Opc(1 TO 6) AS STRING * 15 Cor(0) = "Preto" Cor(1) = "Azul" Cor(2) = "Verde" Cor(3) = "Ciano" Cor(4) = "Vermelho" Cor(5) = "Magenta" Cor(6) = "Marrom" Cor(7) = "Branco" Cor(8) = "Cinza" Cor(9) = "Azul luminoso" Cor(10) = "Verde luminoso" Cor(11) = "Ciano luminoso" Cor(12) = "Vermelho luminoso" Cor(13) = "Rosa" Cor(14) = "Amarelo" Cor(15) = "Branco luminoso" Opc(1) = "Jogador 1" Opc(2) = "Jogador 2" Opc(3) = "Muros" Opc(4) = "Fundo" Opc(5) = "Dilogo (texto)" Opc(6) = "Dilogo (fundo)" RESTORE mono FOR a = 1 TO 6 READ ColorTable(a) NEXT a it = 1: ait = 1 DO IF it = ait THEN COLOR ColorTable(3), ColorTable(4) LOCATE 10, 20: PRINT "" + STRING$(38, "") + ""; FOR i = 11 TO 19 LOCATE i, 20: PRINT "" + SPACE$(38) + ""; NEXT LOCATE 20, 20: PRINT "" + STRING$(38, "") + ""; COLOR ColorTable(1) LOCATE 11, 22: PRINT ""; LOCATE 12, 22: PRINT ""; COLOR ColorTable(2) LOCATE 17, 57: PRINT ""; LOCATE 18, 51: PRINT ""; COLOR ColorTable(5), ColorTable(6) Center 14, "" Center 15, " Abc ? " Center 16, "" END IF FOR i = 1 TO 6 COLOR 7 - 8 * (i = it), 0 Center 3 + i, Opc(i) + ":" + Cor(ColorTable(i)) NEXT ait = it 1 SELECT CASE INKEY$ CASE kup1$: it = it - 1: IF it = 0 THEN it = 6 CASE kdown1$: it = it + 1: IF it = 7 THEN it = 1 CASE kleft1$: ColorTable(it) = ColorTable(it) - 1: IF ColorTable(it) = -1 THEN ColorTable(it) = 15 CASE kright1$: ColorTable(it) = ColorTable(it) + 1: IF ColorTable(it) = 16 THEN ColorTable(it) = 0 CASE "", CHR$(13): EXIT DO CASE "": GOTO 1 END SELECT LOOP ERASE Cor, Opc RETURN END IF FOR a = 1 TO 6 READ ColorTable(a) NEXT a RETURN mono: DATA 15,7,7,0,15,0 normal: DATA 14,13,12,1,15,4 SYSTEM REM $STATIC SUB Center (row, text$) LOCATE row, 41 - LEN(text$) / 2 PRINT text$; END SUB SUB DrawScreen VIEW PRINT COLOR ColorTable(1), ColorTable(4) CLS Center 1, "Nibbles3!" Center 11, "Inicializando Campo de Jogo..." FOR row = 1 TO 50 FOR col = 1 TO 80 arena(row, col).realRow = INT((row + 1) / 2) arena(row, col).sister = (row MOD 2) * 2 - 1 NEXT col NEXT row END SUB SUB EraseSnake (snake() AS snaketype, snakeBod() AS snakeBody, snakeNum) FOR c = 0 TO 9 FOR b = snake(snakeNum).length - c TO 0 STEP -10 tail = (snake(snakeNum).head + MAXSNAKELENGTH - b) MOD MAXSNAKELENGTH Set snakeBod(tail, snakeNum).row, snakeBod(tail, snakeNum).col, ColorTable(4) NEXT b NEXT c END SUB SUB GetInputs (NumPlayers, Speed, difficulty, diff$, monitor$) COLOR 7, 0 CLS LOCATE 5, 1: PRINT SPACE$(80); Center 5, "Quantos Jogadores (1-2) ? " DO: NumPlayers = VAL(INPUT$(1)): LOOP UNTIL NumPlayers = 1 OR NumPlayers = 2 PRINT NumPlayers; LOCATE 6, 1: PRINT SPACE$(80); Center 6, "Atravessar bordas (S/N) ? " DO: borda$ = UCASE$(INPUT$(1)): LOOP UNTIL borda$ = "S" OR borda$ = "N" PRINT borda$; LOCATE 7, 1: PRINT SPACE$(80); Center 7, "Atravessar a si proprio (S/N) ? " DO: itSelf$ = UCASE$(INPUT$(1)): LOOP UNTIL itSelf$ = "S" OR itSelf$ = "N" PRINT itSelf$; LOCATE 8, 21: PRINT "Veloc.(1 A 100)" LOCATE 9, 22: PRINT "1 =Novato" LOCATE 11, 22: PRINT "100=Expert" DO LOCATE 8, 43: PRINT SPACE$(35); LOCATE 8, 43: INPUT gamespeed$ LOOP UNTIL VAL(gamespeed$) >= 1 AND VAL(gamespeed$) <= 100 Speed = VAL(gamespeed$): Speed = (100 - Speed) * 2 + 1 LOCATE 8, 21: PRINT "Nivel (1 A 8) " LOCATE 9, 22: PRINT "1=Novato " LOCATE 11, 22: PRINT "8=Expert " DO LOCATE 8, 43: PRINT SPACE$(35); LOCATE 8, 43: INPUT dfc$ LOOP UNTIL VAL(dfc$) >= 1 AND VAL(dfc$) <= 8 difficulty = VAL(dfc$) LOCATE 15, 1: PRINT SPACE$(80); Center 15, "Aumenta a velocidade durante o jogo (S ou N) ? " DO: diff$ = UCASE$(INPUT$(1)): LOOP UNTIL diff$ = "S" OR diff$ = "N" PRINT diff$; LOCATE 16, 15: PRINT "Definir teclas:"; LOCATE 17, 15: PRINT "P/ cima 1 :"; : DO: kup1$ = INKEY$: LOOP WHILE kup1$ = "": PRINT "Ok"; LOCATE 17, 1: PRINT SPACE$(80); LOCATE 17, 15: PRINT "P/ baixo 1 :"; : DO: kdown1$ = INKEY$: LOOP WHILE kdown1$ = "": PRINT "Ok"; LOCATE 17, 1: PRINT SPACE$(80); LOCATE 17, 15: PRINT "P/ direita 1 :"; : DO: kright1$ = INKEY$: LOOP WHILE kright1$ = "": PRINT "Ok"; LOCATE 17, 1: PRINT SPACE$(80); LOCATE 17, 15: PRINT "P/ esquerda 1 :"; : DO: kleft1$ = INKEY$: LOOP WHILE kleft1$ = "": PRINT "Ok"; LOCATE 17, 1: PRINT SPACE$(80); IF NumPlayers = 2 THEN LOCATE 17, 15: PRINT "P/ cima 2 :"; : DO: kup2$ = INKEY$: LOOP WHILE kup2$ = "": PRINT "Ok"; LOCATE 17, 1: PRINT SPACE$(80); IF kup2$ <> CHR$(0) + "<" THEN LOCATE 17, 15: PRINT "P/ baixo 2 :"; : DO: kdown2$ = INKEY$: LOOP WHILE kdown2$ = "": PRINT "Ok"; LOCATE 17, 1: PRINT SPACE$(80); LOCATE 17, 15: PRINT "P/ direita 2 :"; : DO: kright2$ = INKEY$: LOOP WHILE kright2$ = "": PRINT "Ok"; LOCATE 17, 1: PRINT SPACE$(80); LOCATE 17, 15: PRINT "P/ esquerda 2 :"; : DO: kleft2$ = INKEY$: LOOP WHILE kleft2$ = "": PRINT "Ok"; LOCATE 17, 1: PRINT SPACE$(80); END IF END IF LOCATE 16, 1: PRINT SPACE$(80); LOCATE 17, 1: PRINT SPACE$(80); Center 17, "Esquema de cores: P&B, colorido, novo (P,C ou N) ? " DO: monitor$ = UCASE$(INPUT$(1)): LOOP UNTIL INSTR("PCN", monitor$) PRINT monitor$; startTime# = TIMER FOR i# = 1 TO 1000: NEXT i# stopTime# = TIMER Speed = Speed * .5 / (stopTime# - startTime#) END SUB SUB InitColors FOR row = 1 TO 50 FOR col = 1 TO 80 arena(row, col).acolor = ColorTable(4) NEXT col NEXT row COLOR , ColorTable(4) CLS FOR col = 1 TO 80 Set 3, col, ColorTable(3) Set 50, col, ColorTable(3) NEXT col FOR row = 4 TO 49 Set row, 1, ColorTable(3) Set row, 80, ColorTable(3) NEXT row END SUB SUB Intro SCREEN 0 WIDTH 80, 25 COLOR 15, 0 CLS Center 4, "Q B a s i c N i b b l e s 3" COLOR 7 Center 6, "Copyright (C) WendelSoft Corporation 1997 - 2001" Center 8, "Nibbles3 um jogo para um ou dois jogadores. Movam suas cobras" Center 9, "ao redor da tela tentando comer nmeros enquanto evitam bater em" Center 10, "muros ou outras cobras. Quanto mais nmeros voc come, mais pontos" Center 11, "voc ganha e maior a sua cobra fica. possvel atravessar as paredes" Center 12, "que contornam a tela, mas no as que aparecerem no meio." Center 13, " Controles : " Center 15, " Geral Jogador 1 Jogador 2 " Center 16, " (Up) (Up) " Center 17, "P-Pausa " + CHR$(24) + " W " Center 18, " (Left) " + CHR$(27) + " " + CHR$(26) + " (Right) (Left) A D (Right) " Center 19, " " + CHR$(25) + " S " Center 20, " (Down) (Down) " Center 24, "Pressione qualquer tecla para continuar..." PLAY "MBT160O1L8CDEDCDL4ECC" SparklePause END SUB SUB Level (WhatToDO, sammy() AS snaketype) STATIC SELECT CASE (WhatToDO) CASE STARTOVER CurLevel = 1 CASE NEXTLEVEL CurLevel = CurLevel + 1 END SELECT sammy(1).head = 1 sammy(1).length = 2 sammy(1).alive = TRUE sammy(2).head = 1 sammy(2).length = 2 sammy(2).alive = TRUE InitColors SELECT CASE CurLevel CASE 1 sammy(1).row = 25: sammy(2).row = 25 sammy(1).col = 50: sammy(2).col = 30 sammy(1).direction = 4: sammy(2).direction = 3 CASE 2 FOR i = 20 TO 60 Set 25, i, ColorTable(3) NEXT i sammy(1).row = 7: sammy(2).row = 43 sammy(1).col = 60: sammy(2).col = 20 sammy(1).direction = 3: sammy(2).direction = 4 CASE 3 FOR i = 10 TO 40 Set i, 20, ColorTable(3) Set i, 60, ColorTable(3) NEXT i sammy(1).row = 25: sammy(2).row = 25 sammy(1).col = 50: sammy(2).col = 30 sammy(1).direction = 1: sammy(2).direction = 2 CASE 4 FOR i = 4 TO 30 Set i, 20, ColorTable(3) Set 53 - i, 60, ColorTable(3) NEXT i FOR i = 2 TO 40 Set 38, i, ColorTable(3) Set 15, 81 - i, ColorTable(3) NEXT i sammy(1).row = 7: sammy(2).row = 43 sammy(1).col = 60: sammy(2).col = 20 sammy(1).direction = 3: sammy(2).direction = 4 CASE 5 FOR i = 13 TO 39 Set i, 21, ColorTable(3) Set i, 59, ColorTable(3) NEXT i FOR i = 23 TO 57 Set 11, i, ColorTable(3) Set 41, i, ColorTable(3) NEXT i sammy(1).row = 25: sammy(2).row = 25 sammy(1).col = 50: sammy(2).col = 30 sammy(1).direction = 1: sammy(2).direction = 2 CASE 6 FOR i = 4 TO 49 IF i > 30 OR i < 23 THEN Set i, 10, ColorTable(3) Set i, 20, ColorTable(3) Set i, 30, ColorTable(3) Set i, 40, ColorTable(3) Set i, 50, ColorTable(3) Set i, 60, ColorTable(3) Set i, 70, ColorTable(3) END IF NEXT i sammy(1).row = 7: sammy(2).row = 43 sammy(1).col = 65: sammy(2).col = 15 sammy(1).direction = 2: sammy(2).direction = 1 CASE 7 FOR i = 4 TO 49 STEP 3 Set i - 1, 20, ColorTable(3) Set i, 40, ColorTable(3) Set i + 1, 60, ColorTable(3) NEXT i sammy(1).row = 7: sammy(2).row = 43 sammy(1).col = 65: sammy(2).col = 15 sammy(1).direction = 2: sammy(2).direction = 1 CASE 8 FOR i = 4 TO 40 Set i, 10, ColorTable(3) Set 53 - i, 20, ColorTable(3) Set i, 30, ColorTable(3) Set 53 - i, 40, ColorTable(3) Set i, 50, ColorTable(3) Set 53 - i, 60, ColorTable(3) Set i, 70, ColorTable(3) NEXT i sammy(1).row = 7: sammy(2).row = 43 sammy(1).col = 65: sammy(2).col = 15 sammy(1).direction = 2: sammy(2).direction = 1 CASE 9 FOR i = 6 TO 47 Set i, i, ColorTable(3) Set i, i + 28, ColorTable(3) NEXT i sammy(1).row = 40: sammy(2).row = 15 sammy(1).col = 75: sammy(2).col = 5 sammy(1).direction = 1: sammy(2).direction = 2 CASE ELSE FOR i = 4 TO 49 STEP 3 Set i - 1, 10, ColorTable(3) Set i, 20, ColorTable(3) Set i + 1, 30, ColorTable(3) Set i, 40, ColorTable(3) Set i - 1, 50, ColorTable(3) Set i, 60, ColorTable(3) Set i + 1, 70, ColorTable(3) NEXT i sammy(1).row = 7: sammy(2).row = 43 sammy(1).col = 65: sammy(2).col = 15 sammy(1).direction = 2: sammy(2).direction = 1 END SELECT END SUB FUNCTION NewDir (a, b) IF INT(RND * 2) THEN NewDir = a ELSE NewDir = b END FUNCTION SUB PlayNibbles3 (NumPlayers, Speed, difficulty, diff$) IF ColorTable(1) = ColorTable(4) OR (ColorTable(2) = ColorTable(4) AND NumPlayers = 2) THEN itSelf$ = "N" DIM sammyBody(MAXSNAKELENGTH - 1, 1 TO 2) AS snakeBody DIM sammy(1 TO 2) AS snaketype sammy(1).lives = 5 sammy(1).score = 0 sammy(1).scolor = ColorTable(1) sammy(2).lives = 5 sammy(2).score = 0 sammy(2).scolor = ColorTable(2) Level STARTOVER, sammy() startRow1 = sammy(1).row: startCol1 = sammy(1).col startRow2 = sammy(2).row: startCol2 = sammy(2).col CurSpeed = Speed SpacePause "NIVEL" + STR$(CurLevel) + ", APERTE ESPAO" gameOver = FALSE DO IF NumPlayers = 1 THEN sammy(2).row = 0 END IF FindNum = FALSE Number = 1 nonum = TRUE playerDied = FALSE PrintScore NumPlayers, sammy(1).score, sammy(2).score, sammy(1).lives, sammy(2).lives PLAY "T160O1>L20CDEDCDL10ECC" DO IF nonum = TRUE THEN DO NumberRow = INT(RND(1) * 47 + 3) NumberCol = INT(RND(1) * 78 + 2) sisterRow = NumberRow + arena(NumberRow, NumberCol).sister LOOP UNTIL NOT PointIsThere(NumberRow, NumberCol, ColorTable(4)) AND NOT PointIsThere(sisterRow, NumberCol, ColorTable(4)) NumberRow = arena(NumberRow, NumberCol).realRow nonum = FALSE COLOR ColorTable(1), ColorTable(4) LOCATE NumberRow, NumberCol PRINT RIGHT$(STR$(Number), 1); count = 0 END IF FOR a# = 1 TO CurSpeed: NEXT a# kbd$ = INKEY$ IF kup2$ = CHR$(0) + "<" THEN ro = sammy(2).row co = sammy(2).col bkg = ColorTable(4) nDir = 0 CanGo = 0 Can1 = 0: Can2 = 0 Can3 = 0: Can4 = 0 SELECT CASE sammy(2).direction CASE 1 IF NOT PointIsThere(ro, co - 1, bkg) THEN Can3 = -1 IF NOT PointIsThere(ro, co + 1, bkg) THEN Can4 = -1 IF NOT PointIsThere(ro - 1, co, bkg) THEN CanGo = -1 CASE 2 IF NOT PointIsThere(ro, co - 1, bkg) THEN Can3 = -1 IF NOT PointIsThere(ro, co + 1, bkg) THEN Can4 = -1 IF NOT PointIsThere(ro + 1, co, bkg) THEN CanGo = -1 CASE 3 IF NOT PointIsThere(ro - 1, co, bkg) THEN Can1 = -1 IF NOT PointIsThere(ro + 1, co, bkg) THEN Can2 = -1 IF NOT PointIsThere(ro, co - 1, bkg) THEN CanGo = -1 CASE 4 IF NOT PointIsThere(ro - 1, co, bkg) THEN Can1 = -1 IF NOT PointIsThere(ro + 1, co, bkg) THEN Can2 = -1 IF NOT PointIsThere(ro, co + 1, bkg) THEN CanGo = -1 END SELECT IF CanGo THEN IF NOT FindNum AND INT(RND * 60) = 0 THEN SELECT CASE INT(RND * 4) CASE 0: IF Can1 THEN nDir = 1 CASE 1: IF Can2 THEN nDir = 2 CASE 2: IF Can3 THEN nDir = 3 CASE 3: IF Can4 THEN nDir = 4 END SELECT END IF ELSEIF Can1 AND Can2 THEN IF NumberRow < (ro + 1) \ 2 THEN nDir = 1 ELSEIF NumberRow > (ro + 1) \ 2 THEN nDir = 2 ELSE nDir = INT(RND * 2 + 1) END IF ELSEIF Can3 AND Can4 THEN IF NumberCol < co THEN nDir = 3 ELSEIF NumberCol > co THEN nDir = 4 ELSE nDir = INT(RND * 2 + 3) END IF ELSEIF Can1 THEN nDir = 1 ELSEIF Can2 THEN nDir = 2 ELSEIF Can3 THEN nDir = 3 ELSEIF Can4 THEN nDir = 4 END IF IF nDir > 0 THEN sammy(2).direction = nDir: FindNum = 0 IF NOT FindNum THEN IF co = NumberCol THEN stp = SGN(NumberRow - (ro + 1) \ 2) FindNum = -1 FOR x = ro + stp TO ro + 100 * stp STEP stp IF PointIsThere(x, co, bkg) THEN FindNum = 0: EXIT FOR IF (x + 1) \ 2 = NumberRow THEN EXIT FOR NEXT IF FindNum THEN IF stp = -1 THEN nDir = 1 ELSE nDir = 2 END IF ELSEIF (ro + 1) \ 2 = NumberRow THEN stp = SGN(NumberCol - co) FindNum = -1 FOR x = co + stp TO co + 100 * stp STEP stp IF PointIsThere(ro, x, bkg) THEN FindNum = 0: EXIT FOR IF x = NumberCol THEN EXIT FOR NEXT IF FindNum THEN IF stp = -1 THEN nDir = 3 ELSE nDir = 4 END IF END IF IF nDir > 0 THEN sammy(2).direction = nDir END IF ELSE SELECT CASE kbd$ CASE kup2$: IF sammy(2).direction <> 2 THEN sammy(2).direction = 1 CASE kdown2$: IF sammy(2).direction <> 1 THEN sammy(2).direction = 2 CASE kleft2$: IF sammy(2).direction <> 4 THEN sammy(2).direction = 3 CASE kright2$: IF sammy(2).direction <> 3 THEN sammy(2).direction = 4 END SELECT END IF SELECT CASE kbd$ CASE kup1$: IF sammy(1).direction <> 2 THEN sammy(1).direction = 1 CASE kdown1$: IF sammy(1).direction <> 1 THEN sammy(1).direction = 2 CASE kleft1$: IF sammy(1).direction <> 4 THEN sammy(1).direction = 3 CASE kright1$: IF sammy(1).direction <> 3 THEN sammy(1).direction = 4 CASE "p", "P": SpacePause " JOGO PAUSADO-APERTE ESPAO " CASE "": EXIT SUB END SELECT FOR a = 1 TO NumPlayers SELECT CASE sammy(a).direction CASE 1: sammy(a).row = sammy(a).row - 1: IF sammy(a).row = 3 AND borda$ = "S" THEN sammy(a).row = 49 CASE 2: sammy(a).row = sammy(a).row + 1: IF sammy(a).row = 50 AND borda$ = "S" THEN sammy(a).row = 4 CASE 3: sammy(a).col = sammy(a).col - 1: IF sammy(a).col = 1 AND borda$ = "S" THEN sammy(a).col = 79 CASE 4: sammy(a).col = sammy(a).col + 1: IF sammy(a).col = 80 AND borda$ = "S" THEN sammy(a).col = 2 END SELECT IF NumberRow = INT((sammy(a).row + 1) / 2) AND NumberCol = sammy(a).col THEN PLAY "MBO0L16>CCCE" IF sammy(a).length < (MAXSNAKELENGTH - (8 * difficulty - 2)) THEN sammy(a).length = sammy(a).length + Number * difficulty END IF sammy(a).score = sammy(a).score + Number PrintScore NumPlayers, sammy(1).score, sammy(2).score, sammy(1).lives, sammy(2).lives Number = Number + 1: FindNum = 0 IF Number = 10 THEN EraseSnake sammy(), sammyBody(), 1 EraseSnake sammy(), sammyBody(), 2 LOCATE NumberRow, NumberCol: PRINT " " Level NEXTLEVEL, sammy() PrintScore NumPlayers, sammy(1).score, sammy(2).score, sammy(1).lives, sammy(2).lives SpacePause "NIVEL" + STR$(CurLevel) + ", APERTE ESPAO" IF NumPlayers = 1 THEN sammy(2).row = 0 Number = 1 IF diff$ = "P" THEN CurSpeed = CurSpeed - 10 END IF nonum = TRUE IF CurSpeed < 1 THEN CurSpeed = 1 END IF NEXT a FOR a = 1 TO NumPlayers IF ((PointIsThere(sammy(a).row, sammy(a).col, ColorTable(4)) OR (sammy(1).row = sammy(2).row AND sammy(1).col = sammy(2).col))) AND (PointIsThere(sammy(a).row, sammy(a).col, ColorTable(a) EQV itSelf$ = "S")) THEN PLAY "MBO0L32EFGEFDC" COLOR , ColorTable(4) LOCATE NumberRow, NumberCol PRINT " " playerDied = TRUE sammy(a).alive = FALSE sammy(a).lives = sammy(a).lives - 1 ELSE sammy(a).head = (sammy(a).head + 1) MOD MAXSNAKELENGTH sammyBody(sammy(a).head, a).row = sammy(a).row sammyBody(sammy(a).head, a).col = sammy(a).col tail = (sammy(a).head + MAXSNAKELENGTH - sammy(a).length) MOD MAXSNAKELENGTH Set sammyBody(tail, a).row, sammyBody(tail, a).col, ColorTable(4) sammyBody(tail, a).row = 0 Set sammy(a).row, sammy(a).col, sammy(a).scolor END IF NEXT a LOOP UNTIL playerDied CurSpeed = Speed FOR a = 1 TO NumPlayers EraseSnake sammy(), sammyBody(), a IF sammy(a).alive = FALSE THEN sammy(a).score = sammy(a).score - 10 PrintScore NumPlayers, sammy(1).score, sammy(2).score, sammy(1).lives, sammy(2).lives IF a = 1 THEN SpacePause "Sammy Morreu! Aperte Espao!" ELSE SpacePause "Jake Morreu! Aperte Espao !" END IF END IF NEXT a Level SAMELEVEL, sammy() PrintScore NumPlayers, sammy(1).score, sammy(2).score, sammy(1).lives, sammy(2).lives LOOP UNTIL sammy(1).lives = 0 OR sammy(2).lives = 0 END SUB FUNCTION PointIsThere (row, col, acolor) IF row <> 0 THEN IF arena(row, col).acolor <> acolor THEN PointIsThere = TRUE ELSE PointIsThere = FALSE END IF END IF END FUNCTION SUB PrintScore (NumPlayers, score1, score2, lives1, lives2) COLOR 15, ColorTable(4) IF NumPlayers = 2 THEN LOCATE 1, 1 PRINT USING "#,###,#00 Vidas: # <--JAKE"; score2; lives2 END IF LOCATE 1, 39 PRINT USING "SAMMY--> Vidas: # #,###,#00"; lives1; score1; END SUB SUB Set (row, col, acolor) IF row <> 0 THEN arena(row, col).acolor = acolor realRow = arena(row, col).realRow topFlag = arena(row, col).sister + 1 / 2 sisterRow = row + arena(row, col).sister sisterColor = arena(sisterRow, col).acolor LOCATE realRow, col IF acolor = sisterColor THEN COLOR acolor, acolor PRINT CHR$(219); ELSE IF topFlag THEN IF acolor > 7 THEN COLOR acolor, sisterColor PRINT CHR$(223); ELSE COLOR sisterColor, acolor PRINT CHR$(220); END IF ELSE IF acolor > 7 THEN COLOR acolor, sisterColor PRINT CHR$(220); ELSE COLOR sisterColor, acolor PRINT CHR$(223); END IF END IF END IF END IF END SUB SUB SpacePause (text$) COLOR ColorTable(5), ColorTable(6) Center 11, "" + STRING$(LEN(text$), "") + "" Center 12, " " + text$ + " " Center 13, "" + STRING$(LEN(text$), "") + "" WHILE INKEY$ <> "": WEND WHILE INKEY$ <> " ": WEND COLOR 15, ColorTable(4) FOR i = 21 TO 26 FOR j = 20 TO 60 Set i, j, arena(i, j).acolor NEXT j NEXT i END SUB SUB SparklePause COLOR 4, 0 a$ = "* * * * * * * * * * * * * * * * * " WHILE INKEY$ <> "": WEND WHILE INKEY$ = "" FOR a = 1 TO 5 LOCATE 1, 1 PRINT MID$(a$, a, 80); LOCATE 22, 1 PRINT MID$(a$, 6 - a, 80); FOR b = 2 TO 21 c = (a + b) MOD 5 IF c = 1 THEN LOCATE b, 80 PRINT "*"; LOCATE 23 - b, 1 PRINT "*"; ELSE LOCATE b, 80 PRINT " "; LOCATE 23 - b, 1 PRINT " "; END IF NEXT b NEXT a WEND END SUB FUNCTION StillWantsToPlay COLOR ColorTable(5), ColorTable(6) Center 10, "" Center 11, " FIM DO JOGO ! ! " Center 12, " " Center 13, " JOGA DE NOVO? (S/N) " Center 14, "" WHILE INKEY$ <> "": WEND DO kbd$ = UCASE$(INKEY$) LOOP UNTIL kbd$ = "S" OR kbd$ = "N" COLOR 7, ColorTable(4) Center 10, " " Center 11, " " Center 12, " " Center 13, " " Center 14, " " IF kbd$ = "S" THEN StillWantsToPlay = TRUE ELSE StillWantsToPlay = FALSE COLOR 7, 0 CLS END IF END FUNCTION FUNCTION WantsToReconfig COLOR ColorTable(5), ColorTable(6) Center 10, "" Center 11, " " Center 12, " NOVA CONFIGURACAO? (S/N) " Center 13, " " Center 14, "" WHILE INKEY$ <> "": WEND DO kbd$ = UCASE$(INKEY$) LOOP UNTIL kbd$ = "S" OR kbd$ = "N" COLOR 15, ColorTable(4) Center 10, " " Center 11, " " Center 12, " " Center 13, " " Center 14, " " WantsToReconfig = (kbd$ = "S") END FUNCTION