Re:Show HN: JSRobot – A platform game you play by coding in ...
by kaoD on Monday October 23, 2017 @04:30AM
(#15531633)
I think it's just a case of leaky abstraction. I'd change the API to something like:
Or if you want to keep the action creators:
Which makes it obvious that there can only be a single action per loop call.
[ Parent
| on HN ]
Re:Show HN: JSRobot – A platform game you play by coding in ...
by reacweb on Monday October 23, 2017 @04:40AM
(#15531664)
Or the action could be the return value. IMHO, trying to guess the physical model by experimentation is painful. Why not propose a debug button to display the state of variables during the execution of script.
Re:Show HN: JSRobot – A platform game you play by coding in ...
by positivecomment on Monday October 23, 2017 @06:23AM
(#15532058)
Exactly, the function should not be responsible to see if robot.action has any existing value. It should just return an action depending on the state.
Re:Show HN: JSRobot – A platform game you play by coding in ...
by always_good on Monday October 23, 2017 @07:44AM
(#15532408)
Another idea is to return a map of actions.
{ jump: true, move: 4, shoot: true }
Making the user increment a nonce and use the remainder operator just to do multiple actions simultaneously is pretty heavy.