add the basis for a function which let's the pet sleep
This commit is contained in:
parent
6c58cdd9c4
commit
8f090b951a
|
@ -10,7 +10,6 @@ tamagotchi programme which shouldn't be too hard:
|
|||
* sleeping with all values with over 50% full heals the pet if it has lost health
|
||||
* add pooping and cleaning function
|
||||
* let it get sick if it's health is low, by random chance or if there's too much poop
|
||||
* decrease the hunger value after x seconds
|
||||
* add sleep function, you have to switch the lights off otherwise it will have nightmare and loose one health point.
|
||||
* add the possibility to get sick. Maybe compare two random numbers.
|
||||
* add a function to restart the game or exit it after the pet died.
|
||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -110,7 +110,7 @@ def decrease_poke_count():
|
|||
# run in the background.
|
||||
def decrease_stats():
|
||||
while True:
|
||||
time.sleep(15)
|
||||
time.sleep(pet_variables.day)
|
||||
decrease_hunger()
|
||||
decrease_poke_count()
|
||||
if pet_variables.pet_hunger <= 0:
|
||||
|
@ -163,7 +163,7 @@ def poking():
|
|||
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()
|
||||
increase_poke_count()
|
||||
mixer.init()
|
||||
mixer.music.load('happy.mp3')
|
||||
mixer.music.play()
|
||||
|
@ -175,3 +175,12 @@ def poking():
|
|||
mixer.music.load('angry.mp3')
|
||||
mixer.music.play()
|
||||
time.sleep(3)
|
||||
|
||||
# A function which let's the pet sleep and regenerates it's stats
|
||||
def sleeping():
|
||||
os.system('clear')
|
||||
print("Your pet is sleeping now.")
|
||||
if pet_variables.max_hunger / pet_variables.pet_hunger > 0.5:
|
||||
print("Sleeping works")
|
||||
else:
|
||||
print("Something is broken")
|
||||
|
|
|
@ -22,3 +22,4 @@ owl = "(^0M0^)"
|
|||
# programme variables
|
||||
beginning_finished = False
|
||||
poke_count = 0
|
||||
day = 15
|
||||
|
|
|
@ -31,7 +31,7 @@ while pet_functions.is_alive():
|
|||
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: Poking, 5: Show Stats,")
|
||||
print("4: Poking, 5: Sleeping, 6: Show Stats")
|
||||
try:
|
||||
chosen_activity = int(input("Choose the desired activity:"))
|
||||
if chosen_activity == 1:
|
||||
|
@ -43,6 +43,8 @@ while pet_functions.is_alive():
|
|||
elif chosen_activity == 4:
|
||||
pet_functions.poking()
|
||||
elif chosen_activity == 5:
|
||||
pet_functions.sleeping()
|
||||
elif chosen_activity == 6:
|
||||
pet_functions.pet_stats()
|
||||
except ValueError:
|
||||
pet_functions.pet_stats()
|
||||
|
|
Reference in New Issue