I have a simple shooter game with a GameLevel
class and a Shooter class. The shooter has a set amount of ammo, and every time the shoot()
function is called, the ammo variable in the shooter decreases.
My question is about when the shooter runs out of ammo. Should the shoot()
function be keeping track of ammo and simply stop shooting when ammo is 0, or should the GameLevel
class call some sort of canShoot()
function and have complete control over whether the weapon shoots or not?
This also applies to for example movement limitations i.e. if (in a simple 2D game) the shooter hits a wall, should the shooter itself prevent any movement or should the GameLevel
class check for this first?