[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: A couple of C++ game-related questions
> First of all, is there an STL implementation for Linux? Or something
> similar? What do you guys do for linked lists? Do you make your own/use
> and old one that you made?
An STL implementation is included with g++. A lot of the STL and other
standard C++ features have been added recently so if you want to run on
older systems you may want to limit your use. In general I make limited
use of STL but I'm using an old compiler that doesn't support that much.
(As soon as my new laptop arrives that may change :)
As another option the glib (a piece from gtk) has a linked list
implementation for C.
> Also, I noticed in the Linroids C code, you are making the display
> system portable, but keeping the SVGAlib code in a separate file, right?
> How would you do a similar thing in C++?
Ideally in C++ you would create an abstract base class. This class
would have only pure virtual functions. You would then have a separate
derived class for each display type. The problem then is that your
code then must specify which display type to instantiated. This can
be eliminated by making a factory class or a static function that used
to create the object instead of new. (Unfortunately I don't know of
a good example off the top of my head.)
> Also, wouldn't it be a good idea to separate the input as well? What if
> you wanted to make your game work at the console, as well as with a
> mouse, etc...
In general the input is tied to the display type so yeah it needs a
separate interface as well. If you're thinking along the lines of
swapping a mouse for the keyboard without code change that could be
difficult. I currently have a nintendo controller class that emulates
the input options of the nintendo controller using either a joystick or
the keyboard but I don't think a mouse would work well.