As I press on through the C++ beginner’s game making course, things are starting to get a little more complicated. It’s good, because that will hopefully help me grow as a programmer. I just completed the first part of section 9, and you can see the new changes to JelloStorm on my GitLab!
I ran into a big error that took me a little while to figure out. My lack of experience is what drove the problem, because the compiler told me the solution when it showed me the problem:
JelloStorm.cpp: In function ‘int main()’:
JelloStorm.cpp:203:13: error: ‘currentArrow’ was not declared in this scope
JelloStorm.cpp:69:6: warning: unused variable ‘currentArrows’ [-Wunused-variable]
int currentArrows = 0;
JelloStorm.cpp:385:1: error: expected ‘}’ at end of input
g++: error: JelloStorm.o: No such file or directory
g++: error: Arrow.o: No such file or directory
./build.sh: line 15: ./JelloStorm-app: No such file or directory
type ./JelloStorm-app to launch
There were 3 problems, but two of them were the same issue, I just didn’t realize it.
So, I named a variable currentArrows, and then used currentArrow throughout the rest of the cpp file. Oops. Then it told me that currentArrows was unused, and that currentArrow was not declared. Unfortunately, it took me a little while to realize that I was mistyping my own variable the whole time. Either way, the fix was simple, I renamed the variable to currentArrow to match all the times I used it!
The next issue took a while, but I found Geany to be quite helpful. There was one less “}” (closed curly bracket) then there was supposed to be. The great thing is, if you highlight one curly bracket in Geany, it will highlight it’s mate in blue for you. So I just had to click on each open curly to find the one that didn’t match the closed curly that it should have been, and viola! I found the one that was mis-matched! Added a closed curly, and I was done with this error in under 5 minutes!
Linux – keep it simple.