Skip to content

Comment on Show HN: Virtual pet game made for my daughter

Comments

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){}

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.