Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

In this case I'd argue that the roles are a bit messy and Character has too much knowledge. Character should not know that physics objects can be updated, and certainly shouldn't be calling updatePhysics. You could end up with an updated Character interacting with a Character whose physics state hasn't been updated yet.

applyKnockback: Character -> Physics object -> Physics engine

updatePhysics: Physics engine -> Physics object -> Character new position (x, y)

updateCharacter: Character reacts to change



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: