Use instance variables instead of global variables.
Global Variable is used as common variable, while instance variable makes each type or instance has it own variable so when you have like three instance of the same type, when an instance get hit, it will decrease from its own instance variable, while the others remain undamaged. Hope you find it useful.