Microsoft Small Basic
Program Listing: SBN038
List Program
For i = 1 to 7
TextWindow.WriteLine("")
endfor
TextWindow.ForegroundColor = "yellow"
TextWindow.WriteLine(" ___ ___ ")
TextWindow.WriteLine(" ___________ .__ .__ __ / / _________ \ \ ")
TextWindow.WriteLine(" \_ _____/ ____ _____|__| ____ | |___/ |_ / / \_ ____\ \ \ ")
TextWindow.WriteLine(" | __)_ / \ / ___/ |/ ___\| | \ __\ / / / \ \ \ ")
TextWindow.WriteLine(" | \ | \\___ \| / /_/ > Y \ | ( ( \ \____ ) )")
TextWindow.WriteLine(" /_________/___|__/______>__\___ /|___|__/__| \ \ \________/ / / ")
TextWindow.WriteLine(" /_____/ \__\ /__/ ")
Program.Delay(5000)
menu()
Sub menu
TextWindow.Clear()
TextWindow.ForegroundColor = "cyan"
For i = 1 To 2
TextWindow.WriteLine("")
endfor
TextWindow.WriteLine(" __ __ _ __ __ ")
TextWindow.WriteLine(" | \/ | (_) | \/ | ")
TextWindow.WriteLine(" | \ / | __ _ _ _ __ | \ / | ___ _ __ _ _ ")
TextWindow.WriteLine(" | |\/| |/ _` | | '_ \ | |\/| |/ _ \ '_ \| | | |")
TextWindow.WriteLine(" | | | | (_| | | | | | | | | | __/ | | | |_| |")
TextWindow.WriteLine(" |_| |_|\__,_|_|_| |_| |_| |_|\___|_| |_|\__,_|")
TextWindow.WriteLine("")
TextWindow.WriteLine("")
TextWindow.WriteLine("")
TextWindow.ForegroundColor = "white"
TextWindow.Write(" [")
TextWindow.ForegroundColor = "red"
TextWindow.Write("1")
TextWindow.ForegroundColor = "white"
TextWindow.Write ("] Play Rock Paper Scissors")
TextWindow.WriteLine("")
TextWindow.WriteLine("")
TextWindow.Write(" [")
TextWindow.ForegroundColor = "red"
TextWindow.Write("2")
TextWindow.ForegroundColor = "white"
TextWindow.Write ("] Play Vulcan Rock Paper Scissors")
TextWindow.WriteLine("")
TextWindow.WriteLine("")
TextWindow.Write(" [")
TextWindow.ForegroundColor = "red"
TextWindow.Write("3")
TextWindow.ForegroundColor = "white"
TextWindow.Write ("] Rock Paper Scissors Instructions")
TextWindow.WriteLine("")
TextWindow.WriteLine("")
TextWindow.Write(" [")
TextWindow.ForegroundColor = "red"
TextWindow.Write("4")
TextWindow.ForegroundColor = "white"
TextWindow.Write ("] Vulcan Rock Paper Scissors Instructions")
TextWindow.WriteLine("")
TextWindow.WriteLine("")
TextWindow.Write(" [")
TextWindow.ForegroundColor = "red"
TextWindow.Write("5")
TextWindow.ForegroundColor = "white"
TextWindow.Write ("] Credits")
TextWindow.WriteLine("")
TextWindow.WriteLine("")
TextWindow.Write(" [")
TextWindow.ForegroundColor = "red"
TextWindow.Write("6")
TextWindow.ForegroundColor = "white"
TextWindow.Write ("] Exit program")
TextWindow.WriteLine("")
TextWindow.WriteLine("")
userInput = TextWindow.ReadKey()
If userInput = 1 Then
startRPS()
ElseIf userInput = 2 Then
startVulcan()
ElseIf userInput = 3 Then
instructions()
ElseIf userInput = 4 Then
vulcaninstructions()
ElseIf userInput = 5 Then
credits()
ElseIf userInput = 6 Then
Program.End()
Else
menu()
EndIf
EndSub
Sub instructions
TextWindow.Clear()
TextWindow.WriteLine(" Rock Paper Scissors ")
TextWindow.WriteLine("")
TextWindow.WriteLine(" Instructions")
TextWindow.WriteLine("")
TextWindow.WriteLine(" Rock crushes Scissors, Scissors cut Paper, Paper covers Rock!")
TextWindow.WriteLine("")
TextWindow.WriteLine(" For Rock press R")
TextWindow.WriteLine("")
TextWindow.WriteLine(" For Paper press P")
TextWindow.WriteLine("")
TextWindow.WriteLine(" For Scissors press S")
TextWindow.Pause()
menu()
EndSub
Sub vulcaninstructions
TextWindow.Clear()
TextWindow.WriteLine(" Vulcan Rock Paper Scissors ")
TextWindow.WriteLine("")
TextWindow.WriteLine(" Instructions")
TextWindow.WriteLine("")
TextWindow.WriteLine("Rock crushes Scissors and Lizard, Scissors cut Paper and decapitates Lizard,")
TextWindow.WriteLine("covers Rock and disapproves Spock, Spock vaporizes Rock and smashes Scissors,")
TextWindow.WriteLine("Lizard eats Paper and poisons Spock!")
TextWindow.WriteLine("")
TextWindow.WriteLine(" For Rock press R")
TextWindow.WriteLine("")
TextWindow.WriteLine(" For Paper press P")
TextWindow.WriteLine("")
TextWindow.WriteLine(" For Scissors press S")
TextWindow.WriteLine("")
TextWindow.WriteLine(" For Lizard press L")
TextWindow.WriteLine("")
TextWindow.WriteLine(" For Spock press E")
TextWindow.Pause()
menu()
EndSub
Sub credits
TextWindow.Clear()
TextWindow.WriteLine("-----Rock Paper Scissors!-----")
TextWindow.WriteLine("")
TextWindow.WriteLine(" ---Developers---")
TextWindow.WriteLine("")
TextWindow.WriteLine(" Adrian Ruelas")
TextWindow.WriteLine(" Vincent Teas")
TextWindow.WriteLine("")
TextWindow.WriteLine(" ---Artist---")
TextWindow.WriteLine("")
TextWindow.WriteLine(" Vincent Teas")
TextWindow.WriteLine("")
TextWindow.WriteLine(" Ensight Software (C)")
Program.Delay(3000)
menu()
EndSub
Sub startRPS
playerWin = 0
compWin = 0
ties = 0
round = 1
For i = 1 To 9
RPS()
round = round + 1
EndFor
If playerWin > compWin Then
winner = "player"
ElseIf playerWin = compWin then
winner = "tie"
Else
winner = "computer"
EndIf
year = Clock.Year
If winner = "player" Then
TextWindow.Clear()
TextWindow.Write("You beat the computer [")
TextWindow.ForegroundColor = "green"
TextWindow.Write(playerWin)
TextWindow.ForegroundColor = "white"
TextWindow.Write("] to [")
TextWindow.ForegroundColor = "red"
TextWindow.Write(compWin)
TextWindow.ForegroundColor = "white"
TextWindow.Write("]!")
TextWindow.WriteLine("")
TextWindow.WriteLine("You are now the Rock Paper Scissors Champion of " + year + "!")
TextWindow.Pause()
ElseIf winner = "tie" then
TextWindow.Clear()
TextWindow.WriteLine("You tied to a computer [" + playerWin + "] to [" + compWin + "]!")
else
TextWindow.Clear()
TextWindow.WriteLine("You lost to a computer [" + playerWin + "] to [" + compWin + "]!")
Program.Delay(200)
TextWindow.WriteLine("Don't worry I bet it was programmed to beat you.")
TextWindow.Pause()
EndIf
menu()
EndSub
Sub startVulcan
playerWin = 0
compWin = 0
ties = 0
round = 1
For i = 1 To 9
vulcanRPS()
round = round + 1
EndFor
If playerWin > compWin Then
winner = "player"
ElseIf playerWin = compWin then
winner = "tie"
Else
winner = "computer"
EndIf
year = Clock.Year
If winner = "player" Then
TextWindow.Clear()
TextWindow.Write("You beat the computer [")
TextWindow.ForegroundColor = "green"
TextWindow.Write(playerWin)
TextWindow.ForegroundColor = "white"
TextWindow.Write("] to [")
TextWindow.ForegroundColor = "red"
TextWindow.Write(compWin)
TextWindow.ForegroundColor = "white"
TextWindow.Write("]!")
TextWindow.WriteLine("")
TextWindow.WriteLine("You are now the Vulcan Rock Paper Scissors Champion of " + year + "!")
TextWindow.Pause()
ElseIf winner = "tie" then
TextWindow.Clear()
TextWindow.WriteLine("You tied to a computer [" + playerWin + "] to [" + compWin + "]!")
Else
TextWindow.Clear()
TextWindow.WriteLine("You lost to a computer [" + playerWin + "] to [" + compWin + "]!")
Program.Delay(200)
TextWindow.WriteLine("Don't worry I bet it was programmed to beat you.")
TextWindow.Pause()
EndIf
menu()
EndSub
Sub RPS
mesColor = "white"
TextWindow.ForegroundColor = "white"
TextWindow.Clear()
TextWindow.WriteLine("---Rock Paper Scissors---")
TextWindow.WriteLine("Round [" + round + "]")
TextWindow.Write("Your wins: [")
TextWindow.ForegroundColor = "green"
TextWindow.Write( playerWin )
TextWindow.ForegroundColor = "white"
TextWindow.Write("] Computer wins: [")
TextWindow.ForegroundColor = "red"
TextWindow.Write( compWin )
TextWindow.ForegroundColor = "white"
TextWindow.Write("] Ties: [")
TextWindow.ForegroundColor = "blue"
TextWindow.Write( ties )
TextWindow.ForegroundColor = "white"
TextWindow.Write("]")
TextWindow.WriteLine("")
TextWindow.WriteLine("")
TextWindow.WriteLine("[R] Rock")
TextWindow.WriteLine("[P] Paper")
TextWindow.WriteLine("[S] Scissors")
playerChoice = TextWindow.ReadKey()
compChoice = Math.GetRandomNumber(3)
compSprite = compChoice
If playerChoice = "r" Or playerChoice = "R" Then
playerChoice = 1
playerSprite = 1
ElseIf playerChoice = "p" or playerChoice = "P" Then
playerChoice = 2
playerSprite = 2
ElseIf playerChoice = "s" or playerChoice = "S" Then
playerChoice = 3
playerSprite = 3
Else
RPS()
EndIf
If playerChoice = 1 Then
If compChoice = 1 Then
activity = "It's a tie!"
ties = ties + 1
ElseIf compChoice = 2 Then
mesColor = "red"
activity = "Paper covers Rock!"
compWin = compWin + 1
ElseIf compChoice = 3 Then
mesColor = "green"
activity = "Rock crushes Scissors!"
playerWin = playerWin + 1
EndIf
ElseIf playerChoice = 2 Then
If compChoice = 1 Then
mesColor = "green"
activity = "Paper covers Rock!"
playerWin = playerWin + 1
ElseIf compChoice = 2 Then
activity = "It's a tie!"
ties = ties + 1
ElseIf compChoice = 3 Then
mesColor = "red"
activity = "Scissors cuts Paper!"
compWin = compWin + 1
EndIf
ElseIf playerChoice = 3 Then
If compChoice = 1 Then
mesColor = "red"
activity = "Rock crushes Scissors!"
compWin = compWin + 1
ElseIf compChoice = 2 Then
mesColor = "green"
activity = "Scissors cuts Paper!"
playerWin = playerWin + 1
ElseIf compChoice = 3 Then
activity = "It's a tie!"
ties = ties + 1
EndIf
EndIf
If playerChoice = 1 Then
playerItemColor = "grey"
playerChoice = "Rock"
ElseIf playerChoice = 2 then
playerItemColor = "black"
playerChoice = "Paper"
ElseIf playerChoice = 3 Then
playerItemColor = "purple"
playerChoice = "Scissors"
EndIf
If compChoice = 1 Then
compItemColor = "grey"
compChoice = "Rock"
ElseIf compChoice = 2 then
compItemColor = "black"
compChoice = "Paper"
ElseIf compChoice = 3 Then
compItemColor = "purple"
compChoice = "Scissors"
EndIf
spriteShower()
TextWindow.Write("You chose [")
If playerItemColor = "grey" Then
TextWindow.ForegroundColor = "gray"
ElseIf playerItemColor = "purple" Then
TextWindow.ForegroundColor = "blue"
ElseIf playerItemColor = "black" then
TextWindow.ForegroundColor = "black"
TextWindow.BackgroundColor = "white"
EndIf
TextWindow.Write(playerChoice)
TextWindow.BackgroundColor = "black"
TextWindow.ForegroundColor = "white"
TextWindow.Write("] The computer chose [")
If compItemColor = "grey" Then
TextWindow.ForegroundColor = "gray"
ElseIf compItemColor = "purple" Then
TextWindow.ForegroundColor = "blue"
ElseIf compItemColor = "black" then
TextWindow.ForegroundColor = "black"
TextWindow.BackgroundColor = "white"
EndIf
TextWindow.Write(compChoice)
TextWindow.BackgroundColor = "black"
TextWindow.ForegroundColor = "white"
TextWindow.Write("]")
If mesColor = "red" Then
TextWindow.ForegroundColor = "red"
ElseIf mesColor = "green" Then
TextWindow.ForegroundColor = "green"
Else
TextWindow.ForegroundColor = "white"
TextWindow.BackgroundColor = "black"
EndIf
TextWindow.WriteLine("")
TextWindow.WriteLine(activity)
TextWindow.ForegroundColor = "white"
TextWindow.Pause()
EndSub
Sub vulcanRPS
mesColor = "white"
TextWindow.ForegroundColor = "white"
TextWindow.Clear()
TextWindow.WriteLine("---Vulcan Rock Paper Scissors---")
TextWindow.WriteLine("Round [" + round + "]")
TextWindow.Write("Your wins: [")
TextWindow.ForegroundColor = "green"
TextWindow.Write( playerWin )
TextWindow.ForegroundColor = "white"
TextWindow.Write("] Computer wins: [")
TextWindow.ForegroundColor = "red"
TextWindow.Write( compWin )
TextWindow.ForegroundColor = "white"
TextWindow.Write("] Ties: [")
TextWindow.ForegroundColor = "blue"
TextWindow.Write( ties )
TextWindow.ForegroundColor = "white"
TextWindow.Write("]")
TextWindow.WriteLine("")
TextWindow.WriteLine("")
TextWindow.WriteLine("[R] Rock")
TextWindow.WriteLine("[P] Paper")
TextWindow.WriteLine("[S] Scissors")
TextWindow.WriteLine("[L] Lizard")
TextWindow.WriteLine("[E] Spock")
playerChoice = TextWindow.ReadKey()
compChoice = Math.GetRandomNumber(5)
compSprite = compChoice
If playerChoice = "r" Or playerChoice = "R" Then
playerChoice = 1
playerSprite = 1
ElseIf playerChoice = "p" or playerChoice = "P" Then
playerChoice = 2
playerSprite = 2
ElseIf playerChoice = "s" or playerChoice = "S" Then
playerChoice = 3
playerSprite = 3
ElseIf playerChoice = "l" or playerChoice = "L" Then
playerChoice = 4
playerSprite = 4
ElseIf playerChoice = "e" or playerChoice = "E" Then
playerChoice = 5
playerSprite = 5
Else
vulcanRPS()
EndIf
If playerChoice = 1 Then
If compChoice = 1 Then
activity = "It's a tie!"
ties = ties + 1
ElseIf compChoice = 2 Then
mesColor = "red"
activity = "Paper covers Rock!"
compWin = compWin + 1
ElseIf compChoice = 3 Then
mesColor = "green"
activity = "Rock crushes Scissors!"
playerWin = playerWin + 1
ElseIf compChoice = 4 Then
mesColor = "green"
activity = "Rock crushes Lizard!"
playerWin = playerWin + 1
ElseIf compChoice = 5 Then
mesColor = "red"
activity = "Spock vaporizes Rock!"
compWin = compWin + 1
EndIf
ElseIf playerChoice = 2 Then
If compChoice = 1 Then
mesColor = "green"
activity = "Paper covers Rock!"
playerWin = playerWin + 1
ElseIf compChoice = 2 Then
activity = "It's a tie!"
ties = ties + 1
ElseIf compChoice = 3 Then
mesColor = "red"
activity = "Scissors cuts Paper!"
compWin = compWin + 1
ElseIf compChoice = 4 Then
mesColor = "red"
activity = "Lizard eats Paper!"
compWin = compWin + 1
ElseIf compChoice = 5 Then
mesColor = "green"
activity = "Paper disproves Spock!"
playerWin = playerWin + 1
EndIf
ElseIf playerChoice = 3 Then
If compChoice = 1 Then
mesColor = "red"
activity = "Rock crushes Scissors!"
compWin = compWin + 1
ElseIf compChoice = 2 Then
mesColor = "green"
activity = "Scissors cuts Paper!"
playerWin = playerWin + 1
ElseIf compChoice = 3 Then
activity = "It's a tie!"
ties = ties + 1
ElseIf compChoice = 4 Then
mesColor = "green"
activity = "Scissors decapitates Lizard!"
playerWin = playerWin + 1
ElseIf compChoice = 5 Then
mesColor = "red"
activity = "Spock smashes Scissors!"
compWin = compWin + 1
EndIf
ElseIf playerChoice = 4 Then
If compChoice = 1 Then
mesColor = "red"
activity = "Rock crushes Lizard!"
compWin = compWin + 1
ElseIf compChoice = 2 Then
mesColor = "green"
activity = "Lizard eats Paper!"
playerWin = playerWin + 1
ElseIf compChoice = 3 Then
mesColor = "red"
activity = "Scissors decapitates Lizard!"
compWin = compWin + 1
ElseIf compChoice = 4 Then
activity = "It's a tie!"
ties = ties + 1
ElseIf compChoice = 5 Then
mesColor = "green"
activity = "Lizard poisons Spock!"
playerWin = playerWin + 1
EndIf
ElseIf playerChoice = 5 Then
If compChoice = 1 Then
mesColor = "green"
activity = "Spock vaporizes Rock!"
playerWin = playerWin + 1
ElseIf compChoice = 2 Then
mesColor = "red"
activity = "Paper disproves Spock!"
compWin = compWin + 1
ElseIf compChoice = 3 Then
mesColor = "green"
activity = "Spock smashes Scissors"
playerWin = playerWin + 1
ElseIf compChoice = 4 Then
mesColor = "red"
activity = "Lizard poisons Spock!"
compWin = compWin + 1
ElseIf compChoice = 5 Then
activity = "It's a tie!"
ties = ties + 1
EndIf
EndIf
If playerChoice = 1 Then
playerItemColor = "grey"
playerChoice = "Rock"
ElseIf playerChoice = 2 then
playerItemColor = "black"
playerChoice = "Paper"
ElseIf playerChoice = 3 Then
playerItemColor = "purple"
playerChoice = "Scissors"
ElseIf playerChoice = 4 Then
playerItemColor = "green"
playerChoice = "Lizard"
ElseIf playerChoice = 5 Then
playerItemColor = "blue"
playerChoice = "Spock"
EndIf
If compChoice = 1 Then
compItemColor = "grey"
compChoice = "Rock"
ElseIf compChoice = 2 then
compItemColor = "black"
compChoice = "Paper"
ElseIf compChoice = 3 Then
compItemColor = "purple"
compChoice = "Scissors"
ElseIf compChoice = 4 Then
compItemColor = "green"
compChoice = "Lizard"
ElseIf compChoice = 5 Then
compItemColor = "blue"
compChoice = "Spock"
EndIf
spriteShower()
TextWindow.Write("You chose [")
If playerItemColor = "grey" Then
TextWindow.ForegroundColor = "gray"
ElseIf playerItemColor = "purple" Then
TextWindow.ForegroundColor = "blue"
ElseIf playerItemColor = "blue" Then
TextWindow.ForegroundColor = "magenta"
ElseIf playerItemColor = "green" Then
TextWindow.ForegroundColor = "green"
ElseIf playerItemColor = "black" then
TextWindow.ForegroundColor = "black"
TextWindow.BackgroundColor = "white"
EndIf
TextWindow.Write(playerChoice)
TextWindow.BackgroundColor = "black"
TextWindow.ForegroundColor = "white"
TextWindow.Write("] The computer chose [")
If compItemColor = "grey" Then
TextWindow.ForegroundColor = "gray"
ElseIf compItemColor = "purple" Then
TextWindow.ForegroundColor = "blue"
ElseIf compItemColor = "blue" Then
TextWindow.ForegroundColor = "magenta"
ElseIf compItemColor = "green" Then
TextWindow.ForegroundColor = "green"
ElseIf compItemColor = "black" then
TextWindow.ForegroundColor = "black"
TextWindow.BackgroundColor = "white"
EndIf
TextWindow.Write(compChoice)
TextWindow.BackgroundColor = "black"
TextWindow.ForegroundColor = "white"
TextWindow.Write("]")
If mesColor = "red" Then
TextWindow.ForegroundColor = "red"
ElseIf mesColor = "green" Then
TextWindow.ForegroundColor = "green"
Else
TextWindow.ForegroundColor = "white"
TextWindow.BackgroundColor = "black"
EndIf
TextWindow.WriteLine("")
TextWindow.WriteLine(activity)
TextWindow.ForegroundColor = "white"
TextWindow.Pause()
EndSub
Sub playerRock
line1A = " ______ "
line2A = " / \ "
line3A = " / \ "
line4A = " ____/ \ "
line5A = " / \ "
line6A = " / | "
line7A = " / | "
line8A = " /____________________| "
EndSub
Sub compRock
line1B = " ______"
line2B = " / \"
line3B = " / \"
line4B = " ____/ \"
line5B = " / \"
line6B = " / |"
line7B = " / |"
line8B = " /____________________|"
EndSub
Sub playerScissors
line1A = " \ / "
line2A = " \ / "
line3A = " \ / "
line4A = " V "
line5A = " / \ "
line6A = " / \ "
line7A = " 00 00 "
line8A = " 00 00 "
EndSub
Sub compScissors
line1B = " \ /"
line2B = " \ /"
line3B = " \ /"
line4B = " V"
line5B = " / \"
line6B = " / \"
line7B = " 00 00"
line8B = " 00 00"
EndSub
Sub playerPaper
line1A = " "
line2A = " _____________________ "
line3A = " | | "
line4A = " | | "
line5A = " | | "
line6A = " | | "
line7A = " | | "
line8A = " |_____________________| "
EndSub
Sub compPaper
line1B = ""
line2B = " _____________________ "
line3B = " | |"
line4B = " | |"
line5B = " | |"
line6B = " | |"
line7B = " | |"
line8B = " |_____________________|"
EndSub
Sub compSpock
line1B = " ____"
line2B = " / \"
line3B = " |\ O O /|"
line4B = " |_\ /_|"
line5B = " | _\ |"
line6B = " | |"
line7B = " \____/"
line8B = ""
EndSub
Sub playerSpock
line1A = " ____ "
line2A = " / \ "
line3A = " |\ O O /| "
line4A = " |_\ /_| "
line5A = " | _\ | "
line6A = " | | "
line7A = " \____/ "
line8A = " "
EndSub
Sub playerLizard
line1A = " "
line2A = " __________ "
line3A = " / o \ "
line4A = " / \_____ "
line5A = " ~~\___ _____ ____\ "
line6A = " | | | | "
line7A = " |_| |_| "
line8A = " "
EndSub
Sub compLizard
line1B = ""
line2B = " __________"
line3B = " / o \"
line4B = " / \_____"
line5B = " ~~\___ _____ ____\"
line6B = " | | | |"
line7B = " |_| |_|"
line8B = ""
EndSub
Sub getCompSprite
If compSprite = 1 Then
compRock()
ElseIf compSprite = 2 Then
compPaper()
ElseIf compSprite = 3 Then
compScissors()
ElseIf compSprite = 4 Then
compLizard()
ElseIf compSprite = 5 Then
compSpock()
EndIf
EndSub
Sub spriteShower
If playerSprite = 1 Then
playerRock()
getCompSprite()
ElseIf playerSprite = 2 Then
playerPaper()
getCompSprite()
ElseIf playerSprite = 3 Then
playerScissors()
getCompSprite()
ElseIf playerSprite = 4 Then
playerLizard()
getCompSprite()
ElseIf playerSprite = 5 Then
playerSpock()
getCompSprite()
EndIf
TextWindow.WriteLine(line1A + line1B)
TextWindow.WriteLine(line2A + line2B)
TextWindow.WriteLine(line3A + line3B)
TextWindow.WriteLine(line4A + line4B)
TextWindow.WriteLine(line5A + line5B)
TextWindow.WriteLine(line6A + line6B)
TextWindow.WriteLine(line7A + line7B)
TextWindow.WriteLine(line8A + line8B)
TextWindow.WriteLine("")
EndSub