stuff inside which I don't know yet
This commit is contained in:
parent
3c43fe9ca7
commit
3aee60bbc4
|
@ -7,11 +7,9 @@
|
||||||
Some interesting things I could add to the
|
Some interesting things I could add to the
|
||||||
tamagotchi programme which shouldn't be too hard:
|
tamagotchi programme which shouldn't be too hard:
|
||||||
|
|
||||||
* poke it to make it speak, pokes let it loose a happiness point
|
|
||||||
* sleeping with all values with over 50% full heals the pet if it has lost health
|
* sleeping with all values with over 50% full heals the pet if it has lost health
|
||||||
* add pooping and cleaning function
|
* 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 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 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 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 to restart the game or exit it after the pet died.
|
||||||
|
@ -56,3 +54,6 @@ The feature to the pet the pet will be so that it only prints a message.
|
||||||
It wouldn't be fun if it would increase happiness because that would be
|
It wouldn't be fun if it would increase happiness because that would be
|
||||||
too easy.
|
too easy.
|
||||||
|
|
||||||
|
## 12.07.2015
|
||||||
|
Added the function to poke the pet and it will speak.
|
||||||
|
If you poke to many times it will get angry.
|
||||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -1,14 +1,25 @@
|
||||||
|
# imports the global variables
|
||||||
import pet_variables
|
import pet_variables
|
||||||
|
# imports the time library needed to delay certain functions
|
||||||
import time
|
import time
|
||||||
|
# imports the random library needed to generate a random number for
|
||||||
|
# the guessing game
|
||||||
from random import randint
|
from random import randint
|
||||||
|
# imports the os library needed to clear the terminal
|
||||||
import os
|
import os
|
||||||
|
# imports the pygame library needed to play the sound in the
|
||||||
|
# poking function
|
||||||
|
from pygame import mixer
|
||||||
|
|
||||||
|
|
||||||
# variables needed for the guessing game
|
# variables needed for the guessing game
|
||||||
secret = randint(1, 10)
|
secret = randint(1, 10)
|
||||||
|
|
||||||
|
### Functions providing the basic function of the programm
|
||||||
|
|
||||||
|
# a function which displays the pet's stats in a nice way.'
|
||||||
def pet_stats():
|
def pet_stats():
|
||||||
os.system('clear') #for Linux
|
os.system('clear')
|
||||||
print(pet_variables.pet_name)
|
print(pet_variables.pet_name)
|
||||||
print(pet_variables.pet_photo)
|
print(pet_variables.pet_photo)
|
||||||
print("Status: " + pet_variables.pet_status)
|
print("Status: " + pet_variables.pet_status)
|
||||||
|
@ -60,10 +71,13 @@ def aging():
|
||||||
print("Congratulation your pet has become an elderly it needs now less food.")
|
print("Congratulation your pet has become an elderly it needs now less food.")
|
||||||
print("However it's health is worse and it's grumpier than an adult.")
|
print("However it's health is worse and it's grumpier than an adult.")
|
||||||
|
|
||||||
|
### Functions to increase and decrease stats ###
|
||||||
|
|
||||||
def increase_hunger():
|
def increase_hunger():
|
||||||
pet_variables.pet_hunger = pet_variables.pet_hunger + 1
|
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():
|
def increase_happiness():
|
||||||
if pet_variables.pet_happiness < pet_variables.max_happiness:
|
if pet_variables.pet_happiness < pet_variables.max_happiness:
|
||||||
|
@ -89,6 +103,8 @@ def decrease_health():
|
||||||
if pet_variables.pet_health > 0:
|
if pet_variables.pet_health > 0:
|
||||||
pet_variables.pet_health = pet_variables.pet_health - 1
|
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
|
# The function to decrease the stats and make the pet "live" needs to
|
||||||
# run in the background.
|
# run in the background.
|
||||||
|
@ -96,6 +112,7 @@ def decrease_stats():
|
||||||
while True:
|
while True:
|
||||||
time.sleep(15)
|
time.sleep(15)
|
||||||
decrease_hunger()
|
decrease_hunger()
|
||||||
|
decrease_poke_count()
|
||||||
if pet_variables.pet_hunger <= 0:
|
if pet_variables.pet_hunger <= 0:
|
||||||
decrease_health()
|
decrease_health()
|
||||||
decrease_happiness()
|
decrease_happiness()
|
||||||
|
@ -103,18 +120,20 @@ def decrease_stats():
|
||||||
|
|
||||||
### Activities ###
|
### Activities ###
|
||||||
|
|
||||||
# Increases the pets hungriness by +1 unless the hunger is bigger than
|
# A function which simulates stroking it doesn't have any
|
||||||
# the pet's maximum hunger. In this case the pet will vomit and looses hunger
|
# effect on the pet.
|
||||||
# and health.
|
|
||||||
|
|
||||||
def stroking():
|
def stroking():
|
||||||
os.system('clear') #for Linux
|
os.system('clear')
|
||||||
print()
|
print()
|
||||||
print("You're stroking the back of your pet gently.")
|
print("You're stroking the back of your pet gently.")
|
||||||
print("It makes comforting noises and leans against your hand.")
|
print("It makes comforting noises and leans against your hand.")
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
|
|
||||||
|
# Increases the pets hungriness by +1 unless the hunger is bigger than
|
||||||
|
# the pet's maximum hunger. In this case the pet will vomit and looses hunger
|
||||||
|
# and health.
|
||||||
def feeding():
|
def feeding():
|
||||||
|
os.system('clear')
|
||||||
print("Hungriness of " + pet_variables.pet_name + ": " + pet_variables.pet_hunger * "*")
|
print("Hungriness of " + pet_variables.pet_name + ": " + pet_variables.pet_hunger * "*")
|
||||||
feeding_confirmed = input("Do you want to feed your pet?")
|
feeding_confirmed = input("Do you want to feed your pet?")
|
||||||
if feeding_confirmed in ("Y", "y"):
|
if feeding_confirmed in ("Y", "y"):
|
||||||
|
@ -124,6 +143,7 @@ def feeding():
|
||||||
# A simple guessing game which increases the pet's happiness
|
# A simple guessing game which increases the pet's happiness
|
||||||
def playing():
|
def playing():
|
||||||
guess = 0
|
guess = 0
|
||||||
|
os.system('clear')
|
||||||
while guess != secret:
|
while guess != secret:
|
||||||
g = input("Guess the Number")
|
g = input("Guess the Number")
|
||||||
guess = int(g)
|
guess = int(g)
|
||||||
|
@ -136,3 +156,22 @@ def playing():
|
||||||
print("Too low")
|
print("Too low")
|
||||||
increase_happiness()
|
increase_happiness()
|
||||||
print("Game over!")
|
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():
|
||||||
|
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(3)
|
||||||
|
|
|
@ -21,3 +21,4 @@ owl = "(^0M0^)"
|
||||||
|
|
||||||
# programme variables
|
# programme variables
|
||||||
beginning_finished = False
|
beginning_finished = False
|
||||||
|
poke_count = 0
|
||||||
|
|
|
@ -29,9 +29,10 @@ while pet_functions.is_alive():
|
||||||
print()
|
print()
|
||||||
# Present the player with activities to choose from
|
# Present the player with activities to choose from
|
||||||
print("What would you like to do?")
|
print("What would you like to do?")
|
||||||
print("1: Feeding, 2: Playing, 3: Stroke Pet, 4: Show Stats")
|
|
||||||
# Start the chosen activity and go back to the activity selector.
|
# Start the chosen activity and go back to the activity selector.
|
||||||
try:
|
print("1: Feeding, 2: Playing, 3: Stroke Pet,")
|
||||||
|
print("4: Poking, 5: Show Stats,")
|
||||||
|
try:
|
||||||
chosen_activity = int(input("Choose the desired activity:"))
|
chosen_activity = int(input("Choose the desired activity:"))
|
||||||
if chosen_activity == 1:
|
if chosen_activity == 1:
|
||||||
pet_functions.feeding()
|
pet_functions.feeding()
|
||||||
|
@ -40,6 +41,8 @@ while pet_functions.is_alive():
|
||||||
elif chosen_activity == 3:
|
elif chosen_activity == 3:
|
||||||
pet_functions.stroking()
|
pet_functions.stroking()
|
||||||
elif chosen_activity == 4:
|
elif chosen_activity == 4:
|
||||||
|
pet_functions.poking()
|
||||||
|
elif chosen_activity == 5:
|
||||||
pet_functions.pet_stats()
|
pet_functions.pet_stats()
|
||||||
except ValueError:
|
except ValueError:
|
||||||
pet_functions.pet_stats()
|
pet_functions.pet_stats()
|
||||||
|
|
Reference in New Issue