Tester Game Engine

by Steven Binns: Y12 Age ~17


This program makes it entertaining for a student to complete a test. The user starts by navigating through or around a room and corridor, and will answer a question after a random interval. A correctly answered question provides the chance to attack one of the enemies. The aim is to eliminate all of the enemies before they destroy the player. The player and the enemies are shown in 3D, with the camera panning round the battle scene. Enemies in this engine appear as pyramids, but will be 3D images in a game developed using the engine.


These instructions are taken from the help file supplied with the program.

Controlling the character

To aim the camera (and the direction the player walks towards), move the mouse in the direction you wish the camera to rotate. You can pitch the camera (move it up and down) through 170º and yaw it (move it from side to side) through 360º. You cannot roll the camera (swivel it about an axis parallel to the direction it is facing). Then use the wasd keys to move as follows:
  • w: forwards
  • s: backwards
  • a: left
  • d: right



Navigating Menus

At the user interface presenting menu options, use the wasd keys to position the < at your chosen option then press Enter to confirm the selection. (While you make your selection, you will see the view of the battle scene changing as the camera pans).

Selecting a menu item

Selecting a menu item


In battle, an enemy with a higher speed than you will strike before you.

When you attack by selecting the "Attack" option in the battle menu, you will be presented with a list of enemies to target. After selecting your target a menu will appear with a list of topics.

Selecting a topic

Selecting a topic

Choose a topic, and a question on that topic from the database of questions will appear.

Answering a question

Answering a question

If you answer incorrectly or run out of time (30 seconds by default) you will deal no damage with your attack. If you answer correctly within 5 seconds of the question appearing you will 'critically hit' the enemy, dealing double normal damage. If you answer correctly after 5 seconds you will deal regular damage.

After your attack, any remaining enemies will attack you, dealing damage to your HP (health point total) which is displayed, along with the remaining enemies' HP in the bottom right corner of the user interface.

If your HP is reduced to 0 you will be kicked out of the battle.

OpenGL Code

The OpenGL code is divided into sections for (1) the user interface (2D text) (2) navigation through the 3D room and corridors and (3) panning the 3D battle scene. Steven offers these pieces of advice which he followed when producing his final code.
  • Use depth testing so that only surfaces visible from the current camera position are drawn.
  • Draw rectangles starting from the top right-hand vertex and working anticlockwise around the other vertices in order for the visible coloured side to be drawn.
  • Clear the depth buffer (which is used to order the screen buffer in order of object depth from the camera) before refreshing the screen.
  • Use perspective rendering mode for 3D scenes and orthographic rendering mode for 2D text. See Steven's Start2D and End2D procedures (in the Global Variables unit) for code used in switching between modes.
  • If you do not obtain the desired visual effect, try reordering sections of code. For example, position the screen clearing section of code at the beginning of the drawing phase of the code to enable correct rendering of the 2D graphics.

Setting up the program

For the source code follow the links below. To compile and execute the program you can download tester_game_engine.zip, unzip it and start a new project based on the file TesterGameEngine.lpr. See Getting Started with SDL and SpaceShooter for download details of SDL.dll and SDL_gfx.dll. You also need glut32.dll, OpenGL.dll and opengl32.dll if they are not already on your system. You can download these in the zip files glut32.zip, opengl.zip and opengl32.zip, respectively.

Use program DatabaseEditor to write new tests and to edit existing tests.

Programming - a skill for life!

Seven programs including ALifeSim, Invader, My_first_sdl2 and PlatformDemo by Steven Binns