Guidance
指路人
g.yi.org
software / rapidq / Examples / Game / battle / BATTLE.BAS

Register 
注册
Search 搜索
首页 
Home Home
Software
Upload

  
' Code converted to Rapid-Q by William Yu

'===========================================================================
' Subject: BATTLE OF NUMBERS GAME            Date: Unknown Date (00:00:00)
'  Author: Unknown Author(s)                 Code: QB, QBasic
'    Keys: BATTLE,NUMBER,GAME              Packet: GAMES.ABC
'===========================================================================
     FUNCTION TAB(N AS INTEGER) AS STRING
      TAB = SPACE$(N)
     END FUNCTION


 '----------- PC BATTLE OF NUMBERS GAME ------------
 '
 CLS
'20 WIN$ = ""
 RANDOMIZE VAL(RIGHT$(TIME$, 2))
 M = INT(4 * RND + 5)
 T = INT(19 * RND + 17)
 LOCATE 24, 25
 PRINT CHR$(16); CHR$(16); CHR$(16); " THE BATTLE OF NUMBERS ";
 PRINT CHR$(17); CHR$(17); CHR$(17);
 LOCATE 1, 1
 PRINT "THIS GAME PITS YOU AGAINST THE PC IN A TEST OF ";
 PRINT "MATHMATICAL SKILL. TWO NUMBERS,"
 PRINT "ONE SEVERAL TIMES LARGER THAN THE OTHER,HAVE ";
 PRINT "BEEN SELECTED AT RANDOM. BY TURNS"
 PRINT "BOTH YOU AND THE COMPUTER SUBTRACT AN INTERGER ";
 PRINT "BETWEEN 1 AND ";
 COLOR 15, 0: PRINT M; : COLOR 7, 0: PRINT " FROM THE TOTAL"
 PRINT "LISTED BELOW UNTIL ZERO IS LEFT. WHOEVER MUST ";
 PRINT "MAKE THE FINAL SUBTRACTION IS THE"
 PRINT "LOSER. UNLESS YOU EMPLOY A RATIONAL STRATEGY,";
 PRINT " THE COMPUTER WILL TROUNCE YOU"
 PRINT "EVERY TIME, AND GLOAT ABOUT IT, TOO. ";
 PRINT "THE FIRST TURN IS YOURS -- GOOD LUCK!"
 PRINT CHR$(201); STRING$(28, 205); CHR$(203);
 PRINT STRING$(20, 205); CHR$(203); STRING$(28, 205); CHR$(187);
 PRINT CHR$(186); TAB(28); CHR$(186); TAB(20); CHR$(186); TAB(11);
 PRINT "TOTAL"; TAB(12); CHR$(186);
 PRINT CHR$(186); TAB(28); CHR$(199);
 PRINT STRING$(20, 196); CHR$(182); TAB(28); CHR$(186);
 FOR I = 10 TO 22
  LOCATE I, 1
  PRINT CHR$(186); TAB(28); CHR$(186); TAB(20);
  PRINT CHR$(186); TAB(28); CHR$(186);
 NEXT I
 PRINT CHR$(200); STRING$(28, 205); CHR$(202);
 PRINT STRING$(20, 205); CHR$(202); STRING$(28, 205); CHR$(188);
 PC$ = CHR$(19) + " PC WINS " + CHR$(19)
 PLAYER$ = CHR$(19) + " YOU WIN " + CHR$(19)
 LOCATE 10, 40: PRINT T
 '
 '----------- MAIN STRATEGY LOOP ------------
 '
 FOR I = 10 TO 100 STEP 2
  GOSUB 600'PICK UP PLAYER INPUT
  T = T - P: LOCATE I + 1, 40: PRINT T;
  IF T = 0 THEN: WIN$ = PC$: GOTO 480: END IF
  C = T - ((M + 1) * INT((T - 1) / (M + 1)) + 1)
  IF C = 0 THEN: C = INT(1 + M * RND): END IF
  IF T = 1 THEN: C = 1: END IF
  T = T - C
  LOCATE I + 1, 58: PRINT "PC SUBTRACTS "; C;
  LOCATE I + 2, 40: PRINT T;
  IF T = 0 THEN: WIN$ = PLAYER$: GOTO 480: END IF
 NEXT I
 '
 '--- ANNOUNCE WINNER, SOUND OFF, DISPLAY OPTIONS ---
 '
 COLOR 0, 7: LOCATE 8, 31: PRINT STRING$(4, 32); WIN$; STRING$(5, 32)
 FOR K = 1 TO 2
  FOR J = 3000 TO 400 STEP -300
    'SOUND J, .5
  NEXT J
 NEXT K
 COLOR 7, 0: LOCATE 24, 17
 PRINT "PRESS R TO RUN PROGRAM AGAIN, Q TO QUIT GAME";
 WHILE (X$ <> "q" AND X$ <> "Q")
  X$ = INPUT$(1)
  IF (X$ = "R" OR X$ = "r") THEN: CLS: GOTO 10: END IF
 WEND
 CLS:END
 '
 '------------ PLAYER-INPUT SUBROUTINE -------------
 '
 X = 100
 WHILE 1
  LOCATE I, 7: PRINT "YOU SUBTRACT? ";
  P = VAL(INPUT$(1))
  IF P >= 1 AND P <= M AND P <= T THEN: GOTO 690: END IF
  IF M < T THEN: X = M: ELSE: X = T: END IF
  LOCATE 24, 11: COLOR 15, 0
  PRINT "IMPROPER INPUT. PLEASE ENTER AN INTERGER IN THE RANGE 1 -"; X;
  COLOR 7, 0: LOCATE I, 7: PRINT STRING$(18, 32)
 WEND
 'IF X < 100 THEN KEY ON: KEY OFF
 RETURN
掌柜推荐
 
 
 
 
 
 
 
 
 
 
 
 
© Tue 2024-10-8  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0 Last modified:2000-03-26 23:18:28