switch (difficulty)
{
case 1:
health.max = 5.0;
health.current = 5.0;
mana.max = 40.0;
mana.current = 40.0;
attack.max = 1.5;
attack.current = 1.5;
defence.max = 0;
defence.current = 0;
break;
case 2:
health.max = 3.0;
health.current = 3.0;
mana.max = 20.0;
mana.current = 20.0;
attack.max = 1.0;
attack.current = 1.0;
defence.max = 0;
defence.current = 0;
break;
case 3:
health.max = 1.5;
health.current = 1.5;
mana.max = 10.0;
mana.current = 10.0;
attack.max = 0.5;
attack.current = 0.5;
defence.max = 0;
defence.current = 0;
break;
default:
difficulty = 2;
setup(1); //this is the function that the code is in
break;
}
This code, for example, would be in a function that has the variable, difficulty, given a value when the function is called. I was wondering if it's possible to make this a global variable. Also, the struct is further back, but in the same function
If I understand you correctly define "difficulty" as a global variable, i.e., at the top of the file before an functions start define int difficulty{ 0 };. Then in any other file that needs this variable, in the global scope of the file, define externint difficulty;, or whatever type the variable is.
If it works correctly, I say correctly because I have had program where I had problems using an "extern", this should solve your problem.