Game Development Reference
In-Depth Information
There are a number of ways you can add to this memory system. For example, you
might want to create a simple distributor that creates a number of memory pools of
different sizes and routes memory allocation requests through it. It can return mem-
ory chunks for anything smaller than the size of the largest pool and default to the
global new operator for everything larger. This is exactly what we did on BrainQuest.
Another improvement would be to create a series of macros that would generate the
necessary code required to have a class use a memory pool. That way, you could have
a class use a memory pool with only a couple of lines of code. This is exactly what I
did for the sample code. If you look in MemoryMacros.h , you ' ll see the macro defi-
nitions. An example of their use is in Pathing.h where I pool all of the pathing
nodes. I
'
ll talk more about this in Chapter 18,
An Introduction to Game AI.
Developing the Style That's Right for You
Throughout this chapter, I
ve tried to point out a number of coding techniques and
pitfalls that I ' ve learned over the years. I ' ve tried to focus on the ones that seem to
cause the most problems and offer the best results. Of course, keep in mind that
there is no single best approach or one magic solution for writing a game.
I wish I had more pages because there are tons of gems out there. Most of them
you
'
'
ll beg or borrow from your colleagues. Some of them you
'
ll create for yourself
after you solve a challenging problem.
However you find them, don
'
t forget to share.
Further Reading
C++ Templates: The Complete Guide, Nicolai M. Josuttis and David Vandevoorde
Effective C++, Scott Meyers
More Effective C++, Scott Meyers
Effective STL, Scott Meyers
Design Patterns: Elements of Reusable Object-Oriented Software, Erich Gamma et al.
AntiPatterns: Refactoring Software, Architectures, and Projects in Crisis, William
Brown et al.
Game Programming Gems series, various authors
Thinking in C++ Vol. 1, Bruce Eckel
Thinking in C++ Vol. 2, Bruce Eckel and Chuck Allison
 
 
 
Search WWH ::




Custom Search