From Wikibooks, open books for an open world
Jump to: navigation, search

Delta3D, Ground Floor[edit]

A Quick Scapegoat

Delta3D is a work in progress. There are several very smart people constantly adding, changing, and improving the library for us. They are all marines and work at an aquarium apparently.  : )

This means, somewhat unfortunately, that the "ground floor" can shift a bit here and there as new, cool ideas are implemented.

So, I'd like to say "the following is how ALL Delta3D applications work" but that's skipping the fact that there are now various ways to structure a Delta3D app depending on what you're trying to build.

So, the following is one of the most basic ground floors for Delta3D, but not the only one.

The Ground Floor

In order to have a game you need a game loop. This is some kind of timed, cycling if-then code block that is checking for mouse movement, updating zombies positions, making plasma shots inch slightly closer to the zombies, etc.

Do you program your own loop? NEVER! That would so old-school.

Delta3D takes care of this when you create an instance of the Application class. The Application class has a game loop built into it along with other functions to make useful stuff happen inside the game loop.

So one of the first things you'll see is a variable getting initialized as an Application? NO!

What?! Why?!

Because the Application class has virtual functions, which means its got functions that it really, really wants to make real but doesn't know what their internals should look like. This means you have to provide the internals. Which means you have to "derive" your own class from the Application class, THEN you can create a new variable to store this game instance. So chances are, most Delta3D code you've looked at (or will), will have something like this:

class MainApp : public dtABC::Application

Here our MainApp is OUR class that's derived from the Application class (that is stored in the dtABC 'namespace')

And then somewhere in the main block something like

RefPtr<MainApp> app = new MainApp("config.xml");

Which creates a new variable app to store our MainApp object. Inside app now lives our game loop which can be started with