From 44f4428019c8d1499e076b91ea7d1b268795ebc8 Mon Sep 17 00:00:00 2001 From: Andreas Zweili Date: Sun, 12 Jul 2015 21:10:36 +0200 Subject: [PATCH] adding a function to poke the pet --- README.md | 12 +++------- __pycache__/pet_functions.cpython-34.pyc | Bin 3880 -> 4477 bytes __pycache__/pet_variables.cpython-34.pyc | Bin 504 -> 525 bytes pet_functions.py | 28 +++++++++++++++-------- pet_variables.py | 2 +- tamagotchi.py | 24 +++++++++++-------- 6 files changed, 38 insertions(+), 28 deletions(-) diff --git a/README.md b/README.md index c22c070..4ad6fd9 100644 --- a/README.md +++ b/README.md @@ -1,31 +1,25 @@ # tamagotchi ## Todo -* make the aging work parallel the main programme * adding a function to decrease the health ## Possible things to add Some interesting things I could add to the tamagotchi programme which shouldn't be too hard: -* ~~create a loop~~ -* ~~give it happiness~~ -* ~~give it points for hungriness~~ -* ~~add the guessing game and increase the happiness by one point when you finished the game~~ -* ~~create a list with things you can do~~ -* ~~pet it to increase happiness~~ * poke it to make it speak, pokes let it loose a happiness point -* ~~add max values depending on the status~~ * 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 -* ~~let it age~~ * 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. * add a function let the user exit the game * safe the stats in a text file +* make a seperate function for each age because it makes the aging +funciton more readable +* add a function which lets the tamagotchi age (one week as a youngling, three weeks as an adult and two weeks as an elderly) ## 30.6.2015 Time function has to be implemented otherwise the decrease.* functions diff --git a/__pycache__/pet_functions.cpython-34.pyc b/__pycache__/pet_functions.cpython-34.pyc index 1b11897ef9a9783a82643a2b75c377de1300433e..033c9fa88b2fdd11a82e6380fc9c2dd0bdf2d770 100644 GIT binary patch literal 4477 zcmcInOLH5?5$?re@e(MK5+y2;9S#KkK{_9nu|Iosp3;H*B?FENOr(^CtV|5r@vs!25J17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EWSJ$omz2cDLL89Mj*oZL4q+#m{r~b8r|X)`--T^(=2gmq%-STI2pbXsfiRK~^x*57;B34fUl+UC%{dA!+ zGp+DzzGbVReV07^DxCY1mnS?@Dae(ix8Ntd^llUGR*cS zqk{k+KY*Z`hVe#r6_inZnSk`2CW#t^{XtfL04hQa()tkJE(!&Q+30xq*5N>z8qpz_ z{e^}(iF7JmPxi^3{xeD(NB%L?{3pz_{2f6~P0B!4eUq{xlpP2D za4TzClu~+YG`@*!gKHKAa}ja`R4ik+8pdJT^+ppL_VQ|!__|x=OaC8-tKoF$<*$6j z!riXG*;e3m<`;a}dT|bWZMVkX;K|4^%*3s`wefKu)*r`}#}*Ln1RT&->q delta 1741 zcmaJ>&2Jl35TCc-ws-B=N#nRlN2LBI8-PtR8WN?TB#s9 zkf)hruGx4?o>Ncd#z`o9QhwU+>SVG@_itR4j zKZVpA*s-MsPZGAz((hVLVd@{OONW#~&%}%B*{!&{pZ3h%Myj}o3~kwWJNrr0v+lH# zy`I^5r>#6RhoY9<-RmS#T<=EdNTpn4=FOn1|j-0?<K$()cma130|A6u)*pEzLo#|kR!`z?(3dI78*6XxsR>siRMUZeYtMC@gBfAPMbp77aTx{E&-tET#AW&R(ei!oZ_|<~7XSbN diff --git a/__pycache__/pet_variables.cpython-34.pyc b/__pycache__/pet_variables.cpython-34.pyc index c12e0c7d8626edd9e2a28a07a11c16325cb28bb6..b3332e1df56860f7543b267a9c0bc581b7e5e69e 100644 GIT binary patch delta 132 zcmeyt+{>c;j)#|vVb=W6PDTcX#|%gS$Y*c>;^LHv%6cX&3{mV1Da;H}9AJ`@A%&G8 zii;tIjUkGgA%&eGiiaVEks*qgA%%k>ijN_MlOc+KVtp8+z{G1oJlqATCGo{2`MHV7 U8I#o+H?qkA&1GYpe1}m60319S#sB~S delta 111 zcmeBW`N6FGj)#})mhYU;^Mf8%6fXt3{mV1DL|5gA%&G8ijyIQ zjUkGQA%&eGikl&Yks*qQA%%k>ikBgUlOc+4Vrv*9|HL~%ldTyyu*d)nnf#Ga1^{oo B6x{#- diff --git a/pet_functions.py b/pet_functions.py index d818fc7..072f444 100644 --- a/pet_functions.py +++ b/pet_functions.py @@ -1,17 +1,15 @@ import pet_variables import time from random import randint +import os +from pygame import mixer -# Pictures and symboles used ingame -cat = "(=^o.o^=)__" -mouse = "<:3 )~~~~" -fish = "<`)))><" -owl = "(^0M0^)" # variables needed for the guessing game secret = randint(1, 10) def pet_stats(): + os.system('clear') #for Linux print(pet_variables.pet_name) print(pet_variables.pet_photo) print("Status: " + pet_variables.pet_status) @@ -35,13 +33,13 @@ def beginning(): print("1: Cat, 2: Mouse, 3: Fish, 4: Owl") chosen_pet = int(input("Choose your pet:")) if chosen_pet == 1: - pet_variables.pet_photo = cat + pet_variables.pet_photo = pet_variables.cat elif chosen_pet == 2: - pet_variables.pet_photo = mouse + pet_variables.pet_photo = pet_variables.mouse elif chosen_pet == 3: - pet_variables.pet_photo = fish + pet_variables.pet_photo = pet_variables.fish elif chosen_pet == 4: - pet_variables.pet_photo = owl + pet_variables.pet_photo = pet_variables.owl pet_variables.pet_name = input("How do you want to call your pet?") @@ -111,8 +109,11 @@ def decrease_stats(): # and health. def stroking(): + os.system('clear') #for Linux + 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(): print("Hungriness of " + pet_variables.pet_name + ": " + pet_variables.pet_hunger * "*") @@ -136,3 +137,12 @@ def playing(): print("Too low") increase_happiness() print("Game over!") + +# 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) diff --git a/pet_variables.py b/pet_variables.py index 354c103..2373b74 100644 --- a/pet_variables.py +++ b/pet_variables.py @@ -6,7 +6,7 @@ pet_health = 5 pet_age = 0 pet_hunger = 5 pet_happiness = 5 -pet_stomach +pet_stomach = 0 # age based max values max_health = 5 diff --git a/tamagotchi.py b/tamagotchi.py index 9528506..199db05 100644 --- a/tamagotchi.py +++ b/tamagotchi.py @@ -29,15 +29,21 @@ while pet_functions.is_alive(): print() # Present the player with activities to choose from print("What would you like to do?") - print("1: Feeding, 2: Playing, 3: Show Stats") + 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. - chosen_activity = int(input("Choose the desired activity:")) - if chosen_activity == 1: - pet_functions.feeding() - elif chosen_activity == 2: - pet_functions.playing() - elif chosen_activity == 3: - pet_functions.stroking() - elif chosen_activity == 4: + try: + chosen_activity = int(input("Choose the desired activity:")) + if chosen_activity == 1: + pet_functions.feeding() + elif chosen_activity == 2: + pet_functions.playing() + elif chosen_activity == 3: + pet_functions.stroking() + elif chosen_activity == 4: + pet_functions.poking() + elif chosen_activity == 5: + pet_functions.pet_stats() + except ValueError: pet_functions.pet_stats() print("Your pet died.")