To avoid dependencies, Track
, Atmosphere
, and
Body
were each designed so that they know nothing about the
others. It is the purpose of the World
class to mediate any
interactions among those classes. Because Track
,
Atmosphere
, and Body
are independent, it is neccessary
that World
depend on each of these classes. A subclass of
World
that provides an interface to the input methods of
Car
is provided. It's called Car_World
. (Apologies to
Marcus Hewat, creator of the Carworld program,
http://perso.club-internet.fr/hewat/carworld/carworld.htm.
Aside from some bits of code I stole for reading textures from files
and drawing text on the screen, this project is unrelated to
Carworld.)
World o ^ o o---. / | \ \ Track | Body Atmosphere | ^ Car_World | o | \ | Car
The World
base class doesn't do any graphics. If you want to see
the results of the simulation on screen, you must derive an appropriate
class and define the draw()
method. An example of such a class
that uses OpenGL, Gl_Car_World
, is provided. You must also use
subclasses of Track and Car (such as Gl_Track
and Gl_Car
)
that use the same graphics system if you wish to see instances of those
objects.
A typical application will construct a Track
, Atmosphere
,
and Car
, and then construct a World
by passing pointers to those
objects. The simulation is started by calling the World
's
start()
method. The World
is responsible for initializing the
graphics system (if used) and starting the event loop.