11-13-2018, 07:57 AM
So, I'm trying to work through the KamaKazi Base InvaderStart code and ran into a few issues.
The first thing is that there was a switch from using Objects to GameObject. The book mentions that Game Objects Classes from the previous example, but there was only an Objects class.
The describes adding the code for Star.h and Star.cpp, however part of that code includes using Rand but this is not defined anywhere in the project so the IDE/Compiler complains. I added this to GameObjects.h since it was in Objects previously. I hope this is okay.
Also, in GameObject.cpp OBJID is assigned the value of NumberOfObjectsCreated++ however with Eclipse and the GNU Linker with c++11 I am getting an undefined reference for 'GameObjects::NumberOfObjectsCreated. After some Googling, I found I had to add the following initialization code at the top of GameObject.cpp.
int GameObject::NumberOfObjectsCreated = 0;
This eliminated the Linker error.
After this and adding the code for Star, I am still not getting stars to show when the code is run as is mentioned on page 126.
The first thing is that there was a switch from using Objects to GameObject. The book mentions that Game Objects Classes from the previous example, but there was only an Objects class.
The describes adding the code for Star.h and Star.cpp, however part of that code includes using Rand but this is not defined anywhere in the project so the IDE/Compiler complains. I added this to GameObjects.h since it was in Objects previously. I hope this is okay.
Also, in GameObject.cpp OBJID is assigned the value of NumberOfObjectsCreated++ however with Eclipse and the GNU Linker with c++11 I am getting an undefined reference for 'GameObjects::NumberOfObjectsCreated. After some Googling, I found I had to add the following initialization code at the top of GameObject.cpp.
int GameObject::NumberOfObjectsCreated = 0;
This eliminated the Linker error.
After this and adding the code for Star, I am still not getting stars to show when the code is run as is mentioned on page 126.