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).

Usage example:

1 final class MyGame : GameHelperBase {
2 	/// Called when it is time to redraw the frame
3 	/// it will try for a particular FPS
4 	override void drawFrame() {
5 		glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_ACCUM_BUFFER_BIT);
6 
7 		glLoadIdentity();
8 
9 		glColor3f(1.0, 1.0, 1.0);
10 		glTranslatef(x, y, 0);
11 		glBegin(GL_QUADS);
12 
13 		glVertex2i(0, 0);
14 		glVertex2i(16, 0);
15 		glVertex2i(16, 16);
16 		glVertex2i(0, 16);
17 
18 		glEnd();
19 	}
20 
21 	int x, y;
22 	override void update(Duration deltaTime) {
23 		x += 1;
24 		y += 1;
25 	}
26 
27 	override SimpleWindow getWindow() {
28 		auto window = create2dWindow("My game");
29 		// load textures and such here
30 		return window;
31 	}
32 
33 	final void fillAudioBuffer(short[] buffer) {
34 
35 	}
36 }
37 
38 void main() {
39 	auto game = new MyGame();
40 
41 	runGame(game, maxRedrawRate, maxUpdateRate);
42 }

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

More...

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

runGame
void runGame(T game, int maxUpdateRate = 20, int maxRedrawRate = 0)

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

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.

Suggestion Box / Bug Report