I am writing a Duck Hunt program. The problem in detail is that when I type the correct number, the score variable does not go up. I was wondering if the variable "duckL" was being initialized more than once and that "board1" was not being updated.
I don't understand what the problem is.
You might want to move the srand call outside of the loop, but I don't think that's the issue you're talking about.
In Board.h in the function "drawBoard()" put the call to "srand" in "main" not here. This function only needs called once. Not everytime that you call the function. If you call "srand" to soon you could end up with the same number.
In Board.h in the function "drawBoard()" you define int duckL = (rand() % 12) + 1;. When you reach the closing } of the function this variable is destroyed and its value lost. Try making "duckL" a static variable. That way when the function ends the variable and the value will not.
In the function "main" use a while or do/while loop and get rid of the "goto"s. "goto" still has a rare use, but this is not 1 of them. the loop is much better.
"Sleep" is good, lol, but 100 milliseconds does not give much of a noticeable delay. You need something like 200 milliseconds or above.
keskiverto while loop example is a start, but there is no way out of it.
Sorry about that. I have no idea how I got fixed on "duckL" being the problem. The first 2 paragraphs I wrote have nothing to do with the problem.
After running the code a few times I realized that "int location" and "int score;" are defined as global variables in the header file and so become global variables in the ".cpp" file. So adding to the "score" does not become a problem.
When I ran the code in MSVS 2017 the program appeared to do what it should, the best I could tell.
I did have a problem with trying to figure out what needed to be entered and when. Your output to the screen could use a little work.
I was wondering if the class is required because I do not see much use for it right now. I could say that you could just as easily use a "struct", but that is still more than you need.
The variables that you need are all global outside the class and the function does not need a class to work. It just seems like extra work that is not needed.
If you got the program to work for you that is good.