Download create computer games
Transcript
plies a number by itself a certain number of times. On some versions of BASIC, such as Applesoft, this should be replaced by a circumflex symbol (~) and on others, such as Commodore BASIC, by a symbol that looks like an upward pointing arrow (1). If player 1 has placed markers on all squares in the diagonal, then the result of multiplying the values in all of those squares together (as we have done above) will be 1 multiplied by itself three times, or 1. If player 2 has placed markers in all three squares, then the result of multiplying the values together will be 2 multiplied by itself three times, or 8. Thus, we can see if any player has occupied all squares in the diagonal by checking if the result of this multiplication is 1 or 8. Finally, we must loop back, draw the board again, and let the other player make a move: 360 GOTO 90 : REM DO IT AGAIN When the game is over, we must print a picture of the board and congratulate the winner: 370 GOSUB 1000 : REM ** DRAW TIC-TAC-TOE BOARD ** 380 PRINT "CONGRATULATIONS, PLAYER";CP;"-YOU WON!" 390 PRINT HAVE As before, we will let the players decide whether to play again: 400 410 420 430 440 PRINT "PLAY AGAIN? (1 =YES, 2=NO)" INPUT Q IF Q=1 THEN GOTO 30 : REM IF YES, PLAY AGAIN IF Q=2 THEN END: REM IF NO, END PROGRAM GOTO 400: REM IF NEITHER, ASK AGAIN Here is the complete tic-tac-toe program: [60]