2 ms·
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
by kowdermeister 9y ago
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.