Using what I am learning in my programming classes, I am making a small text-based turn based combat game in C++. Keep in mind that I may not know how to use or be aware of more complex concepts.
I have a lot of variables in the game, bools for checking whether the player has certain items, ints for health, armor, etc. I know I shouldn't use global variables, so I was going to use pointers to pass variables between functions.
Normally this wouldn't be a problem:
attack(int *health, int *armor);
but I have something resembling this:
attack(int *health, int *armor, int *enemyHealth, int *enemyArmor, ......etc);
It's becoming tedious to type and using global variables would be an instant solution. But I want to know of another way. Also, sometimes when calling a function I don't need to pass "*armor" for example if the player isn't wearing any. This also means I need to create a lot of these:
if (*armor != nullptr)
{
do things
}
Solutions? Sorry in advance if this wasn't clear. I'm new to this site and it might take me awhile to understand your answers. Thanks all!! :)
Here is the full code (There aren't many instances of this problem yet as I have just ran into it, but looking at my function calls will make it somewhat clear)