Skip to content

Core Objects

Leeor Dicker edited this page Mar 3, 2017 · 2 revisions

NAS2D's interface is defined through a series of core objects that represent all of the major facilities you'll need to build most types of games.

The following sections describe the various objects available for you to use in your applications and will introduce you to some of the ideology and terminology used throughout NAS2D and its interfaces.


Game

For a quick and easy way to start your application, you can create a Game object that will handle instantiation of all of the utility objects, provide you options for mounting additional file paths and archives and gives you a default application loop.


Filesystem

The Filesystem provides a virtual filesystem that can seamlessly read files from archives and can read and write files from the host operating system's native FS. When using the Filesystem object, the application can only read and write to specified directory paths.

It provides support for several common archive formats including ZIP, WAD, PAK, PK2 HOG and 7z formats (and a few others). You will likely only be using ZIP or 7z formats.


Renderer

All games need a way to draw graphics to the screen and the Renderer does exactly this. The Renderer interface provides a variety of functions for drawing images and graphics primitives such as lines, circles and points to the screen. The Renderer takes the approach of typical graphics blitters from previous generation graphics libraries and maintains simplicity by maintaining this interface.

In its original incarnation both a software SDL based Renderer and an OpenGL based Renderer were provided. As of release 1.0, only the OpenGL Renderer is available. This allows NAS2D applications to take advantage of advanced visual effects only possible using programmable GPU pipelines such as OpenGL GLSL shader programs. Future versions of NAS2D may also provide Vulkan and DirectX variants of the Renderer.


Mixer

As with graphics, all games need a way to play multiple audio samples and background music. The Mixer provides a simple interface to do exactly this.


EventHandler

Games and applications need a way of responding to input from the keyboard, joystic and mouse. The EventHandler takes advantage of a Signals & Slots pattern and raises signals when certain events occur. In addition to basic input device events, the EventHandler also responds to some windowing events such as minimize, maximize, activate and several others.


Configuration

The Configuration object is optional and provides a simple way to store and retrieve application configuration options applicable to typical games as well as custom defined key/value paired values.


StateManager

This is a convenience object provided as a simple means of managing State objects. Generally speaking you won't work with these directly unless you opt to not use the Game object's implementation.