
Show HN: Virtual pet game made for my daughter - ben85ts
https://bsawyer.github.io/tamagotchi/index.html
======
RugnirViking
Personally, I think a little more feedback into what effect each action has
would be good. I couldn't figure out if the buttons did anything at all except
change the animation. Perhaps a status bar showing the hunger/thirst/boredom
going up or whatever.

The animations and the aestetic are great though!

~~~
AllanHoustonSt
I thought clicking around different combinations of buttons to discover what
would happen was part of the fun. I kept trying to kill it to no avail.

~~~
Loughla
I'm actually laughing out loud at that statement.

>What a neat game, let's see what it does. Nah. Let's kill it.

Humans. So weird.

------
nkrisc
I've never seen this pattern before in JS, in the parameters for the
constructor. playing with it in the browser, I can see it lets you define
default values for expected arguments when calling it but you can provide
other values.

What is this called? I'd like to read more about it.

    
    
      class Resource{
        constructor({
          min = 0,
          max = 1,
          count = 0
        }={}){
          this.min = min;
          this.max = max;
          this.count = count;
        }
      }

~~~
orisa2
From the post, I wasn't sure if you knew, but JS also has regular default
parameters if that's all you want.

~~~
capableweb
Not as nice though, as the arguments still depend on the order. Passing a
object gives the benefit of named arguments AND position of the arguments no
longer matter (as object keys don't have order and also, it's a object with
key/values)

------
yomansat
Github code
[https://github.com/bsawyer/tamagotchi](https://github.com/bsawyer/tamagotchi)

~~~
ghostbrainalpha
I've never said this before but, I really wanted a read.me file for this...

------
minhajuddin
Love the game! It would be nice to wrap this up in an Android app and put it
on the market place just because when I build games like these my kids end up
closing the browser somehow :) I built a few of these at:
[http://putty.minhajuddin.com/](http://putty.minhajuddin.com/)

~~~
ben85ts
That’s a really good idea!

------
JDiculous
Looks amazing! How did you make the SVG/animations?

I'm just a developer, but seeing stuff like this really makes me want to learn
design.

~~~
ben85ts
Just separating different css transform animations across nested divs

~~~
JDiculous
How did you make the SVGs though? Did you draw them yourself, or get them
somewhere else?

~~~
ben85ts
Drew them in figma

~~~
JDiculous
Thanks! I had never thought to draw in Figma.

------
tofu_ink
console javascript hacking ;)

var ele = document.createElement('div'); ele.setAttribute('id', 'foo');
//$('.stage').append("<div id='foo'>m</div>");
document.getElementsByClassName('stage')[0].appendChild(ele);

var dict = { pain: { energy: 'paddle', waste: 'needs to fart' }, sad: { ideas:
'coffee' }, frustration: { fatigue: 'sleep', energy: 'food' // 'paddle' },
restless: { concentration: 'knit?', waste: 'fart' }, tired: { fatigue: 'needs
sleep' } };

// happy concentration // estatic ideas / waste // restless waster

trigger = setInterval(function() { var s = getState(STATE); var msg =
s.mood.name + ' ' \+ s.mood.reason ; if (dict[s.mood.name] &&
dict[s.mood.name][s.mood.reason]) msg = dict[s.mood.name][s.mood.reason]; var
other = ['concentration','energy','fatigue','ideas','waste']; for (var i = 0;
i < other.length; ++i) msg += ' ' \+ other[i] + ':' \+
(s.creature[other[i]].count).toFixed(1);

    
    
        document.getElementById('foo').innerHTML = '<small>'+ msg +'</small>';

}, 100)

/* i couldnt find the mute button */ function playSound(state, sound){}

------
dynamite-ready
Great artstyle. You should make it a fully fledged PWA. I would have
downloaded it in a heartbeat.

------
throwaway35784
I like the style of the code. Can talk about your inspiration for it? I
haven't seen Javascript written in that way before. It's clean but, at least
to me, unintuitive. What is your background?

~~~
ben85ts
Been a frontend dev for 10 years angular and react. You’re right it’s a little
mix of functional state management and imperative structures for the game
objects.

------
rmetzler
I try to find the time to write a small game for my daughter for so long! I'm
jealous. Good job!

~~~
ben85ts
Thank you! It is definitely hard to find time. Certainly helped that she
wanted to “help”(she’s 6) write it with me sometimes :)

------
workthrowaway
great job! only a couple of seconds with the game and i felt calmed down
somehow lol we need more slow paced, calming things like this

~~~
trianglem
Try playing death stranding. It’s very calming making “deliveries” while
enjoying the great graphics and music.

------
Fnoord
I've been playing Pwnagotchi with my daughter. (Not really, cause she's still
too young.) Thanks for the inspiration though.

------
Aeolun
Ah, my heart. It was sad for such a long time and I just didn’t know what it
wanted.

Reminds me of my son until he was 1 year old(ish).

------
mobilemidget
great :) add more stuff, I cant teach my daughter things can live on coffee
and cookies... just kidding of course we can :)

------
tobyhinloopen
Neat

~~~
ben85ts
Thanks, glad you like it!

------
natex
Can you add a brown face choice? Right now the choices are peach (caucasian)
or alien.

~~~
htk
Caucasian? It’s an imaginary pet, not a person.

~~~
Aeolun
Even for an imaginary pet brown makes perfect sense though?

------
ravenstine
Very cute! Maybe someday this will inspire her to learn how to code. :)

------
t0astbread
It's very cute!

------
shakna
I'd rename it. Tamagotchi is still a trademarked name, and someone still owns
it and produces toys with the name.

Ignoring that, it seems a fun little thing. I have trouble understanding the
faces, but I assume that just takes practice.

It's pretty neat, fast, with the all-important cute animations that trick you
into caring about a state machine.

~~~
ben85ts
You’re absolutely right, would love any suggestions!

~~~
romes
perhaps emotchi

~~~
warent
I give this the millennial stamp of approval

