TGC Codebase Backup



Rock Paper Scissors Game by WRappiii

11th Jul 2008 23:23
Summary

First attempt at a "game". Simple rock paper scissors game that keeps track of wins, losses, and ties. I would be grateful for constructive criticism.



Description



Code
                                    ` This code was downloaded from The Game Creators
                                    ` It is reproduced here with full permission
                                    ` http://www.thegamecreators.com
                                    
                                    set text size 24 : set text font "Arial" : set text to bold

set cursor 180,10
print "ROCK, PAPER, SCISSORS!!!"
set text size 18 : set cursor 180,30
print "Press any key to begin..."
wait key

wins = 0
losses = 0
ties = 0
gosub start

start:
   cls
   set cursor 170,50
   print "Wins: ";wins;"   Losses: ";losses;"     Ties: ";ties
   set cursor 170,30
   print "Press 'SPACE' to QUIT."
   if spacekey() = 1 then end
   set cursor 170,10
   input " 1 for ROCK, 2 for PAPER, 3 for SCISSORS... ";playerchoice
   if playerchoice = 1 then playerchoicetxt$ = "ROCK"
   if playerchoice = 2 then playerchoicetxt$ = "PAPER"
   if playerchoice = 3 then playerchoicetxt$ = "SCISSORS"
   cls
   aichoice = rnd (3)
   if aichoice = 0 then aichoice = 1
   if aichoice = 1 then aichoicetxt$ = "ROCK"
   if aichoice = 2 then aichoicetxt$ = "PAPER"
   if aichoice = 3 then aichoicetxt$ = "SCISSORS"
   gosub compare

compare:
   cls
   if playerchoice = 1 and aichoice = 2 then gosub aiwin
   if playerchoice = 1 and aichoice = 3 then gosub playerwin
   if playerchoice = 2 and aichoice = 1 then gosub playerwin
   if playerchoice = 2 and aichoice = 3 then gosub aiwin
   if playerchoice = 3 and aichoice = 1 then gosub aiwin
   if playerchoice = 3 and aichoice = 2 then gosub playerwin
   if playerchoice = aichoice then gosub tie

aiwin:
   losses = losses + 1
   set cursor 170,10
   print "You Lose!!!"
   set cursor 170,30
   print aichoicetxt$;" beats ";playerchoicetxt$;"!!!"
   set cursor 170,50
   print "Press any key to try again..."
   set cursor 170,70
   wait key
   gosub start

playerwin:
   wins = wins + 1
   set cursor 170,10
   print "You Win!!!"
   set cursor 170,30
   print playerchoicetxt$;" beats ";aichoicetxt$;"!!!"
   set cursor 170,50
   print "Press any key to try again..."
   wait key
   gosub start

tie:
   ties = ties + 1
   set cursor 170,10
   print "It's a Tie!!!"
   set cursor 170,30
   print "Press any key to try again..."
   wait key
   gosub start