![](/images/wygolvillage%20logo.png)
LocalPet - Locally Hosted Widget! ![](/images/batgif.gif)
![](/images/batdivider.gif)
If there's anything I love about having a little web-menagerie, it's having little interactive pets. And online, there are tons of little pet widgets you can use like Gifypet, Webneko, anything by abowman, BunnyHeroLabs, etc. I absolutely love them! But the only problem with these awesome projects is that they're hosted on someone else's site. That's fine, but it would definitely suck if those sites ever get shut down, leaving the widget on your own site completely nonfunctional. So, I decided to make my own little widget, with some extremely simple interactive features. The idea is that everything within is hosted on YOUR site alone, and once you copy-paste the code, it's yours forever. The CSS can be fully customized to your liking, you can add your own features, and it can accomodate any page adopt or cyber pets you might have collected on your site and wished you could pet or feed.
The only graphics you'll need are three bowls (empty, full of food, and full of water), your adopt, a background of your choosing, and 6 stat bars (feel free to yoink the ones I made, pictured below).
![](/pets/mypets/happinessbar1.png)
![](/pets/mypets/happinessbar2.png)
![](/pets/mypets/hungerbar1.png)
![](/pets/mypets/hungerbar2.png)
![](/pets/mypets/thirstbar1.png)
![](/pets/mypets/thirstbar2.png)
Your widget may flicker or glitch a little when swapping out images, this can be avoided by making your pet and bowl images the same height in pixels by including some empty space above the food bowl images, setting a different height for your pet, or by including a transparent image (like this one) and setting its height to be the same as the tallest image in the row. There are many options and workarounds!
Put it all together and define some widths and heights and you get something like this:
![(Click to fill Lucy's food bowl.)](/pets/mypets/bbbowlempty.png)
![(Click to fill Lucy's water bowl.)](/pets/mypets/bbbowlempty.png)
![(Lucy licks at her paw idly. She looks a little bored. Perhaps you should pet her!)](/pets/mypets/lucy1.png)
![](/pets/mypets/hungerbar1.png)
![](/pets/mypets/thirstbar1.png)
![](/pets/mypets/happinessbar1.png)
So, here's the script. Anything in ALL CAPS!!! must be changed for everything to work. And if you have multiple pets on one page, make sure they each have unique IDs for their stat bars, the pet, and their food and water bowls.
Of course, once you have your LocalPet set up, you can add whatever you want to it to make it more immersive. Here are some quick ideas that you might enjoy as low-stakes coding challenges:
-Context-specific cursors for filling the food bowl, water bowl and petting your adoptable.
-Sound effects that play on click.
-A cleanliness bar that fills up once you click and drag a brush. (See the Stable in my Clovenglade shrine for an example)
-Code a timer that resets the stat bars after a certain amount of time if the tab stays open.
-Click and drag toys to arrange inside your pet's room.
-A way to switch the background and take your pet on "vacation".
And more! You can do anything with LocalPet, as the whole idea is that everything contained within it is yours alone. It will survive as long as your website does, which is kind of the point. The code is a tad spaghetti-ish but I hope you enjoy and find it useful or fun!
![](/images/back%20button.png)