diff --git a/__pycache__/pet_functions.cpython-34.pyc b/__pycache__/pet_functions.cpython-34.pyc index 033c9fa..995218f 100644 Binary files a/__pycache__/pet_functions.cpython-34.pyc and b/__pycache__/pet_functions.cpython-34.pyc differ diff --git a/angry.mp3 b/angry.mp3 new file mode 100644 index 0000000..c3b1c99 Binary files /dev/null and b/angry.mp3 differ diff --git a/happy.mp3 b/happy.mp3 new file mode 100644 index 0000000..0827414 Binary files /dev/null and b/happy.mp3 differ diff --git a/pet_functions.py b/pet_functions.py index 0b7dcbc..54e231d 100644 --- a/pet_functions.py +++ b/pet_functions.py @@ -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) diff --git a/pet_variables.py b/pet_variables.py index 2373b74..9fa9ca1 100644 --- a/pet_variables.py +++ b/pet_variables.py @@ -21,3 +21,4 @@ owl = "(^0M0^)" # programme variables beginning_finished = False +poke_count = 0 diff --git a/sound.mp3 b/sound.mp3 deleted file mode 100644 index 2935ff0..0000000 Binary files a/sound.mp3 and /dev/null differ diff --git a/tamagotchi.py b/tamagotchi.py index 97f056d..1be77c8 100644 --- a/tamagotchi.py +++ b/tamagotchi.py @@ -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: