2.1 Creating a sprite

By Charles Quarra, charsquarra@hotmail.com.

I will assume you already has initialized the following pointers that every CS aplication needs to fully interact with the framework:

ObjectRegistry* object_reg; // this should go on the declaration
object_reg = csInitializer::CreateEnvironment (argc, argv); // object registry

// the following loads the basic plugins for CrystalSpace
csInitializer::RequestPlugins (object_reg,
      CS_REQUEST_VFS,
      CS_REQUEST_SOFTWARE3D,
      CS_REQUEST_ENGINE,
      CS_REQUEST_FONTSERVER,
      CS_REQUEST_IMAGELOADER,
      CS_REQUEST_LEVELLOADER,
      CS_REQUEST_REPORTER,
      CS_REQUEST_REPORTERLISTENER,
      CS_REQUEST_PLUGIN("crystalspace.collisiondetection.rapid",
           iCollideSystem),
      CS_REQUEST_END));

// the event handler!!
csInitializer::SetupEventHandler (object_reg, SimpleEventHandler);
// i dont really know for sure about this line; just include it
csCommandLineHelper::CheckHelp (object_reg);

// now it's safe to load all the other CS pointers
iEngine* engine; //remember to put declarations in the proper spot!
iLoader* loader;
iGraphics3D* g3d;
iKeyboardDriver* kbd;
iVirtualClock* vc;
iSector* room;
iView* view;
iCollideSystem* cdsys;

cdsys = CS_QUERY_REGISTRY (object_reg, iCollideSystem); // collider system
vc = CS_QUERY_REGISTRY (object_reg, iVirtualClock); // virtual clock
engine = CS_QUERY_REGISTRY (object_reg, iEngine); // the engine
loader = CS_QUERY_REGISTRY (object_reg, iLoader); // the loader, so you dont need to define everything
g3d = CS_QUERY_REGISTRY (object_reg, iGraphics3D); // the 3D grahics plugin
kbd = CS_QUERY_REGISTRY (object_reg, iKeyboardDriver); // do you want to interact properly?

csInitializer::OpenApplication (object_reg); // you can't start all the previous settings without this

NOTE: The model for many of the tutorial files is the application Simple2, which should include all data necessary for the first tutorials. The Crystal Space User's Manual contains a pretty full tutorial of how to create a sprite, so no further information is necessary here (note to self: ask for permission to reprint sections of the User's Manual).