Posts: 192
Threads: 21
Joined: Aug 2018
Reputation:
17
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.
Posts: 693
Threads: 186
Joined: Jan 2018
Reputation:
1
thanks for the feedback, Ill check this afternoon though I am only using my VisualGDB set up, but I am using GNU compiler so it should throw the same errros...
tell you what, can you mail me your project directory, and I'll set a system the same as yours so we can see the same errors?
Brian Beuken
Lecturer in Game Programming at Breda University of Applied Sciences.
Author of The Fundamentals of C/C++ Game Programming: Using Target-based Development on SBC's
Posts: 693
Threads: 186
Joined: Jan 2018
Reputation:
1
use my email brian@scratchpadgames.net
Brian Beuken
Lecturer in Game Programming at Breda University of Applied Sciences.
Author of The Fundamentals of C/C++ Game Programming: Using Target-based Development on SBC's
Posts: 693
Threads: 186
Joined: Jan 2018
Reputation:
1
11-14-2018, 09:29 PM
(This post was last modified: 11-14-2018, 09:30 PM by Brian Beuken.)
Thanks for sending Jon, you have in fact got the code working just fine, remember its not a complete game, but a base on which to build the Kamikazi project, follow the book instructions, not all of which are now explicitly spelled out, but have been previously explained. (I hope??) and you can build your Kamikazi game from the ground up.
First thing to do is make use of that nice star class you have and put a few stars in the project, then worry about the aliens using what you learned when doing invaders.
Keep pinging back here with any issues you have.
Brian Beuken
Lecturer in Game Programming at Breda University of Applied Sciences.
Author of The Fundamentals of C/C++ Game Programming: Using Target-based Development on SBC's
Posts: 192
Threads: 21
Joined: Aug 2018
Reputation:
17
Brian, Thanks, but the point I was trying to make is that in the book it states on page 128 to compile and run the code with the edits up to that point and you should see the star pattern on the screen. I still think I am missing something since all I see is the Alien, or cluster of in the same location, in the upper left corner.
I tried to add this to the Game Update method as was done in the previous example, however since Star includes a reference to Game so that caused a compiler error.
I'll have another look at this and see what I am missing.
Posts: 693
Threads: 186
Joined: Jan 2018
Reputation:
1
oh sorry, I misunderstood, I will try to check that out, if I have missed out a working starfield I'll add it to the download files
Brian Beuken
Lecturer in Game Programming at Breda University of Applied Sciences.
Author of The Fundamentals of C/C++ Game Programming: Using Target-based Development on SBC's
Posts: 192
Threads: 21
Joined: Aug 2018
Reputation:
17
Okay, I have had a bit of success.
Using the same code I sent you, I was able to get single random traveling blinking star to appear.
The first thing I had to do was remove the '#include "Game.h"' from Star.h since when adding Star.h to Game.h this creates a circular reference and fails to compile.
In Game.h i created a reference to a Star object:
Star* MyStars;
in the GameInit method, i added an initialization for the MyStars object under the other references.
MyStars = new Star();
In Game::Update, I added a call to the Stars Update method under the AlienGroup->Update call;
MyStars->UpDate(this);
Then under the loop for Game::MyObjects I added a call to the Star Draw method.
MyStars->Draw(a_Screen);
This compiles and runs without a SigFault and produces a single Star that blinks and changes different colors as well as travels down the screen at random locations once it gets to the bottom of the screen. The thing I am missing is having a screen full of stars but it is a bit closer.
Should I be using Game::MyObjects for these?
Also, is the right place for this posting or should it go under "Help my code won't work??"?
Posts: 192
Threads: 21
Joined: Aug 2018
Reputation:
17
Okay, I pulled my head out of my crack and found all I needed to do was mimic what was done in the previous project for the Shelters and create an array of Stars and display them.
Now I have a nice screen full of twinkling stars rolling down the screen.
There might be a better way but it seems to work.
Thanks.
Posts: 192
Threads: 21
Joined: Aug 2018
Reputation:
17
Okay, moving to the next step with The Ship / Shooter, the code listed in the book does not compile.
The constructor for Shooter with the GameObject base class initialization list will not compile if placed in the Header file as is shown on page 129. This needs to be moved to .cpp file instead.
Thus in the Shooter.h should just have:
Shooter(char* filename, MyFiles* filehandler);
and Shooter.cpp file , the constructor should look like:
Shooter::Shooter(char* filename, MyFiles* filehandler) : GameObject (filename, filehandler)
{
}
Otherwise, I get a compiler redefinition error for Shooter::Shooter.
Also, at the bottom of page 129, it states " ... let's get our init systems to create our ship and try moving him around a bit.". However, on the next page the book jumps to "Da Baddies!". Is it assumed the reader will understand what to do next?