Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Page 94 is different from 95 Names[i]
Hmm yes it is, most of the code in those pages is descriptive rather than code you have to expressly type in.. I see now (from my student Kim who's struggling a bit) that its obvious to an experienced coder but not a very new coder.

So, my bad, for not being as clear as I need to be.

At the start of the discussion on page 94, I'm using a constructor like this

Aliens::Aliens(char*, MyFiles*);

Where the char* passed would be an entry from the Names[] array.

But by the bottom of 95 I am using Aliens(int, MyFiles*)
where I am only passing the i rather than the full string in names. I wrote a different constructor which then used the array...I'll change that back to avoid confusion.

That was me optimising the code a little later and pasting in the new version, but either way, here's a bit of advice, don't slavishly type in the code, there's intended to be a little room for you to adapt it to your needs, which is great if you know C++, but clearly very confusing if its all new to you. I'm sorry about that but I have said before this is not a book for absolute beginners.

Use which ever method you want, I expect you to write your constructors and call them as you choose, I've detailed both ways but not shown all the code. I'll review that though and make sure I only show one working way, so that beginners don't get confused and expect both constructor calls to work with only 1 type of constructor.

Also you don't need to create an AlienList I'm simply explaining how we "could" use arrays to hold our enemies, but we'd end up needing multiple arrays for different things, which leads us on to using a MyObjects vector to hold, almost all of them...

A lot of the books source code from Chapter5 on, is there to be descriptive and is mostly incomplete, sometimes partially lifted from source code, you should have the C++ skills to evaluate it and fill in a few blanks or change a few bits to suit what you are doing.

But if anything isn't clear, please just let me know I'm always happy to explain and push you pass a confusion roadblock, all beginners get them and I'm happy to help.
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 


Forum Jump:

Users browsing this thread: 1 Guest(s)