News for hackers. Stuff that matters.
Re:Global Mutable State by kowdermeister on Tuesday September 19, 2017 @06:57PM (#15289490)
Well, it's kinda bad idea for the bullet to have access to everything. It can lead to a lot of mess later on. Global state is not your problem here.

An object shouldn't have access to independent objects, like a wall or another player.

I'd implement an observer pattern (or some other pattern) so you can safely decouple your bullet class say from the wall object.

    UserAction -> bulletFiredMessage -> bullet fires and travels
                                     -> wall receives message -> wall starts to poll if there was an impact
                                     -> boss entity does the same
It's probably not a really good example, but you see state remains in objects.

There are no comments on this comment yet.