9 ms·
Show HN: Virtual pet game made for my daughter
- yomansat 7y agoGithub code https://github.com/bsawyer/tamagotchi https://github.com/bsawyer/tamagotchi
- ghostbrainalpha 7y agoI've never said this before but, I really wanted a read.me file for this...
- tobyhinloopen 7y agoNeat
- ben85ts 7y agoThanks, glad you like it!
- rmetzler 7y agoI try to find the time to write a small game for my daughter for so long! I'm jealous. Good job!
- ben85ts 7y agoThank you! It is definitely hard to find time. Certainly helped that she wanted to “help”(she’s 6) write it with me sometimes :)
- shakna 7y agoI'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 7y agoYou’re absolutely right, would love any suggestions!
- workthrowaway 7y agogreat 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 7y agoTry playing death stranding. It’s very calming making “deliveries” while enjoying the great graphics and music.
- Fnoord 7y agoI've been playing Pwnagotchi with my daughter. (Not really, cause she's still too young.) Thanks for the inspiration though.
- throwaway35784 7y agoI 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?
- beaconstudios 7y agonot the author, but it looks Java-like to me - with the "everything is an object/class" approach.
- ben85ts 7y agoBeen 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.
- nkrisc 7y agoI'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; } }
- chiyc 7y agoI think I would call it nested destructuring with default values.
- nkrisc 7y agoDestructuring, that rings a bell. Thank you.
- capableweb 7y agoYeah, the trick is basically many things chained together. First is to pass a object to a function instead of position-locked arguments. Second is to default to a empty object. Third is to destruct the object in the function parameter directly. Fourth to supply default destruct values. Fifth is to set the values in the current instance of that class.
- deleted 7y ago[deleted]
- orisa2 7y agoFrom the post, I wasn't sure if you knew, but JS also has regular default parameters if that's all you want.
- capableweb 7y agoNot 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)
- JDiculous 7y agoLooks 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.
- t0astbread 7y agoIt's very cute!
- RugnirViking 7y agoPersonally, 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 7y agoI 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 7y agoI'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.
- jboy55 7y agojust put debug=1 into the location bar.
- bluejedi 7y agoI did it, no wonder it has exhausted face, the fatigue bar is too high
- clarkey252 7y agoI think that this is supposed to be similar to the classic tamagotchi's off of the 90's. There were no status bars (like a real pet) and figuring it out was part of the charm . I do think that if the pet is really hungry/thirsty/tired there should be an a different animation, like pointing to mouth for hunger. I agree animations and aesthetic are awesome (much better than the original LCD pixel Tamagotchi's).
- deleted 7y ago[deleted]
- minhajuddin 7y agoLove 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 7y agoThat’s a really good idea!
- natex 7y agoCan you add a brown face choice? Right now the choices are peach (caucasian) or alien.
- tofu_ink 7y agoconsole 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){}
- ravenstine 7y agoVery cute! Maybe someday this will inspire her to learn how to code. :)
- dynamite-ready 7y agoGreat artstyle. You should make it a fully fledged PWA. I would have downloaded it in a heartbeat.
- Aeolun 7y agoAh, 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 7y agogreat :) add more stuff, I cant teach my daughter things can live on coffee and cookies... just kidding of course we can :)