Virtual Pet Programming

We're going to make a very simplified Virtual Pet program, which, as we indicated, is a kind of simulation. You can buy virtual pet toys (like a keychain with a small screen) and download virtual pet software. There are also web sites like Neopets and Webkinz, which are forms of virtual pets. All of these, of course, are simulations as well. They mimic the behavior of a living thing and get hungry, lonely, tired, and so on. To keep them happy and healthy, you have to feed them, play with them, or take them to the doctor.

Our virtual pet will be a lot simpler and less realistic than the ones you can buy or download because I just want to give you the basic idea, and I don't want the code to get too complicated. But you could take our simple version and expand or enhance it as much as you want.

Here are the features our program will have:

■ The pet will have four different activities that you can do: feed it, walk it, play with it, or take it to the doctor.

■ The pet will have three stats that you can monitor: hunger, happiness, and health.

Hunger j j

Happiness I_

Health I__

Hunger j j

Happiness I_

Health I__

■ Hunger will increase over time. You can reduce hunger by feeding.

■ Hunger will increase more slowly when the pet is asleep.

■ If the pet is asleep and you do any activity, it will wake up.

■ If the pet gets too hungry, its happiness will decrease.

■ If the pet gets very, very hungry, its health will decrease.

■ Walking the pet will make both its happiness and health increase.

■ Playing with the pet will make its happiness increase.

■ Taking the pet to the doctor will make its health increase.

■ The pet will have six different graphics:

■ one for being awake but doing nothing.

The graphics will use some simple animation. In the next few sections, we'll see how this all goes together in a program.

+2 -1

Responses

  • ari-pekka
    How to make a virtual pet using python?
    6 years ago

Post a comment