adding the sound files for angry and happy sounds

This commit is contained in:
Andreas Zweili 2015-07-12 21:47:52 +02:00
parent ee090b61a2
commit aa64579cbe
7 changed files with 26 additions and 10 deletions

BIN
angry.mp3 Normal file

Binary file not shown.

BIN
happy.mp3 Normal file

Binary file not shown.

View File

@ -17,7 +17,7 @@ secret = randint(1, 10)
def pet_stats():
os.system('clear') #for Linux
os.system('clear')
print(pet_variables.pet_name)
print(pet_variables.pet_photo)
print("Status: " + pet_variables.pet_status)
@ -73,6 +73,8 @@ def aging():
def increase_hunger():
pet_variables.pet_hunger = pet_variables.pet_hunger + 1
def increase_poke_count():
pet_variables.poke_count = pet_variables.poke_count + 1
def increase_happiness():
if pet_variables.pet_happiness < pet_variables.max_happiness:
@ -98,6 +100,8 @@ def decrease_health():
if pet_variables.pet_health > 0:
pet_variables.pet_health = pet_variables.pet_health - 1
def decrease_poke_count():
pet_variables.poke_count = pet_variables.poke_count - 1
# The function to decrease the stats and make the pet "live" needs to
# run in the background.
@ -105,6 +109,7 @@ def decrease_stats():
while True:
time.sleep(15)
decrease_hunger()
decrease_poke_count()
if pet_variables.pet_hunger <= 0:
decrease_health()
decrease_happiness()
@ -117,13 +122,14 @@ def decrease_stats():
# and health.
def stroking():
os.system('clear') #for Linux
os.system('clear')
print()
print("You're stroking the back of your pet gently.")
print("It makes comforting noises and leans against your hand.")
time.sleep(1)
def feeding():
os.system('clear')
print("Hungriness of " + pet_variables.pet_name + ": " + pet_variables.pet_hunger * "*")
feeding_confirmed = input("Do you want to feed your pet?")
if feeding_confirmed in ("Y", "y"):
@ -133,6 +139,7 @@ def feeding():
# A simple guessing game which increases the pet's happiness
def playing():
guess = 0
os.system('clear')
while guess != secret:
g = input("Guess the Number")
guess = int(g)
@ -149,8 +156,18 @@ def playing():
# let's you poke the pet and it will talk
# if you poke it more than 3 times it will get angry at you
def poking():
print("You poke " + pet_variables.pet_name + " and it starts to speak.")
mixer.init()
mixer.music.load('sound.mp3')
mixer.music.play()
time.sleep(5)
os.system('clear')
if pet_variables.poke_count < 4:
print("You poke " + pet_variables.pet_name + " and it starts to speak.")
pet_variables.increase_poke_count()
mixer.init()
mixer.music.load('happy.mp3')
mixer.music.play()
time.sleep(5)
else:
print("You annoyed " + pet_variables.pet_name "It got angry at you.")
decrease_happiness()
mixer.init()
mixer.music.load('angry.mp3')
mixer.music.play()
time.sleep(5)

View File

@ -21,3 +21,4 @@ owl = "(^0M0^)"
# programme variables
beginning_finished = False
poke_count = 0

BIN
sound.mp3

Binary file not shown.

View File

@ -29,11 +29,9 @@ while pet_functions.is_alive():
print()
# Present the player with activities to choose from
print("What would you like to do?")
# Start the chosen activity and go back to the activity selector.
print("1: Feeding, 2: Playing, 3: Stroke Pet,")
print("4: Stroking, 5: Show Stats,")
# Start the chosen activity and go back to the activity selector.
print("1: Feeding, 2: Playing, 3: Stroke Pet, 4: Show Stats")
# Start the chosen activity and go back to the activity selector.
try:
chosen_activity = int(input("Choose the desired activity:"))
if chosen_activity == 1: