An example of a main.cpp-file with a class "GameApp"

Note: This method requires much work and detailed knowledge of this engine. Especially beginners should use the XmlApp example An example of a main.cpp-file with the class XmlApp.

In every Netrinjo-program, a variable of a class derived from BasicApp has to be initialized. Otherwise Netrinjo-classes cannot be used.

Here an example (GameApp is here a class, derived from BasicApp):

int the_main( int argc, char *argv[] );

int main( int argc, char *argv[] )
{
    return the_main( argc, argv );
}

#include "SDL/SDL.h"// "SDL.h" cannot be included before main, if compiling with mingw
#include "gameapp.h"// header file which declares GameApp

int the_main( int argc, char *argv[] )
{
    BasicApp::chDirToUser();
    if( !BasicApp::setWorkingDir( "./.game-dir" ) )
        return -1;
    GameApp app( argc, argv );

    if( SDL_Init( 0 ) < 0 ) {
        app.logLine("ERROR: could not init SDL");
        return -2;
    }
    atexit( SDL_Quit );

    app.init();// ignore fail-status (so i.e. audio need not be captured)

    return app.mainLoop();
}
In GameApp::init you can perform all operations that you need to initialize variables...
Generated on Wed May 9 17:36:09 2007 for netrinjo by  doxygen 1.5.1