arsd.gamehelpers

An add-on for simpledisplay.d, joystick.d, and simpleaudio.d that includes helper functions for writing games (and perhaps other multimedia programs). Whereas simpledisplay works with an event-driven framework, gamehelpers always uses a consistent timer for updates.

Usage example:

final class MyGame : GameHelperBase {
	/// Called when it is time to redraw the frame
	/// it will try for a particular FPS
	override void drawFrame() {
		glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_ACCUM_BUFFER_BIT);

		glLoadIdentity();

		glColor3f(1.0, 1.0, 1.0);
		glTranslatef(x, y, 0);
		glBegin(GL_QUADS);

		glVertex2i(0, 0);
		glVertex2i(16, 0);
		glVertex2i(16, 16);
		glVertex2i(0, 16);

		glEnd();
	}

	int x, y;
	override bool update(Duration deltaTime) {
		x += 1;
		y += 1;
		return true;
	}

	override SimpleWindow getWindow() {
		auto window = create2dWindow("My game");
		// load textures and such here
		return window;
	}

	final void fillAudioBuffer(short[] buffer) {

	}
}

void main() {
	auto game = new MyGame();

	runGame(game, maxRedrawRate, maxUpdateRate);
}

It provides an audio thread, input scaffold, and helper functions.

More...

Public Imports

arsd.color
public import arsd.color;
Undocumented in source.
arsd.simpledisplay
public import arsd.simpledisplay;
Undocumented in source.
arsd.simpleaudio
public import arsd.simpleaudio;
Undocumented in source.
core.time
public import core.time;
Undocumented in source.
arsd.joystick
public import arsd.joystick;
Undocumented in source.

Members

Classes

GameHelperBase
class GameHelperBase

This is the base class for your game.

OpenGlTexture
class OpenGlTexture

Simple class for putting a TrueColorImage in as an OpenGL texture.

Functions

clearOpenGlScreen
void clearOpenGlScreen(SimpleWindow window)
runGame
void runGame(T game, int maxUpdateRate, int maxRedrawRate)

The max rates are given in executions per second Redraw will never be called unless there has been at least one update

Structs

VirtualController
struct VirtualController

The virtual controller is based on the SNES. If you need more detail, try using the joystick or keyboard and mouse members directly.

Detailed Description

The MyGame handler is actually a template, so you don't have virtual function indirection and not all functions are required. The interfaces are just to help you get the signatures right, they don't force virtual dispatch at runtime.

Meta