Last active
August 15, 2017 20:13
-
-
Save jonathans199/8a3f2c3f820381d9d9df1bd83ddc6f05 to your computer and use it in GitHub Desktop.
Simple Game
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# clears screen | |
system "clear" | |
#defines method to add and center the **** | |
def add_asterisks_withtext(text) | |
puts ("*"*100).center(110) | |
sleep 1 | |
puts text.center(110) | |
sleep 1 | |
puts ("*"*100).center(110) | |
sleep 1 | |
end | |
def add_asterisks | |
puts ("*"*100).center(110) | |
end | |
#add the text into (argument) of add_asterisks | |
add_asterisks_withtext("WELCOME TO MY GAME") | |
puts "TYPE YOUR NAME".center(110) | |
name = gets.chomp.center(110) | |
#gets users name | |
add_asterisks | |
puts " ", "TYPE YOUR CHOICE".center(110) | |
puts "Options: | |
CAT | |
DOG | |
OTHER".center(110) | |
option = gets.chomp | |
#gets users option | |
# | |
#this is setting a class as string, for the color text on the answer | |
class String | |
def red; "\033[31m#{self}\033[0m" end | |
def green; "\033[32m#{self}\033[0m" end | |
end | |
#loop begins | |
case option | |
when "dog" | |
puts " | |
_._ | |
.-'66|| ,;' | |
(O ,:|/.----..;' | |
`=' \_ ____ | | |
||| ||| | |
||| ||| | |
mm' mm' | |
".red.center(110) | |
when "cat" | |
puts " | |
/|__/\ | |
| | | |
_ * * _ | |
- /_/ - | |
--- | |
".green | |
else | |
puts " | |
#{name} you should have a pet".green | |
end | |
add_asterisks_withtext("THANK YOU FOR PLAYING") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment