Writing a 2D or 3D appliction using the acknex engine is a lot easier than writing a general Windows application. There are only three functions that you need to know:
///////////////////////////////////////////////////////////////
// ackexe.cpp : Tutorial Application, Lesson 1
///////////////////////////////////////////////////////////////
// Include the usual Windows headers
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <stdlib.h>
#include <malloc.h>
#include <memory.h>
#include <tchar.h>
// Include the engine data types, variables, and functions
#include "adll.h"
///////////////////////////////////////////////////////////////
// Lesson 1: Writing an application with just four lines of C
///////////////////////////////////////////////////////////////
// This is the Windows main function. It's executed at start
// of the application. Don't be confused by the scary looking
// arguments, we normally won't need any.
int APIENTRY WinMain(HINSTANCE hInstance, // application instance handle
HINSTANCE hPrevInstance, // always zero
LPTSTR lpCmdLine, // application command line
int nCmdShow) // window flags
{
// If you're used to windows programming, you would normally expect
// here about 150 lines of window definition, class registration,
// and message loop stuff. You can do that if you want and override
// the engine defaults, but all you really need is:
engine_open("arena.wmb");
// The engine_open() function initializes the Gamestudio engine,
// and accepts a command line string with the name of a script,
// or an entity file to be loaded upon initialization. For instance,
// we could hand over the application command line (char*)lpCmdLine.
// We could also pass options to start in client or server mode.
// Here we're just loading the arena level.
// After loading a level we're ready to render it. The engine_frame()
// function executes the scripts and physics, and renders the
// current camera position to the screen if a level is loaded.
// The function returns zero when a script calls exit() or an Abort
// button is clicked.
while (engine_frame());
// For rendering the level, we are just repeating engine_frame() until
// a 0 value is returned. This is normally our main loop, all
// the interesting stuff happens here. However, when an entity file
// name is given for engine_open(), the engine acts as a viewer.
// A default walkthrough movement is activated and we don't want
// to do anything else at the moment.
engine_close();
// Someone pressed the Exit icon. Our application is about to end.
// Before that, the engine must be closed by engine_close().
return 0;
}
► latest version online