FANDOM


This page talks you through a very, very simple program. It is intended for beginners, and will explain how a DarkGDK program is laid out and how it works. This program moves a cube forwards. Fun!


The Program Edit

#include "DarkGDK.h"

void DarkGDK ( void )
{
	dbSyncOn   ( );
	dbSyncRate ( 60 );

	dbMakeObjectCube ( 1, 1);
	
	dbPositionCamera ( 10, 10, -20 );

	while ( LoopGDK ( ) )
	{
		dbMoveObject( 1, 0.5 );

		dbSync ( );
	}

	dbDeleteObject ( 1 );

	return;
}



void DarkGDK ( void ) Edit

This is the start of the function which is run automatically when a GDK program starts. All the commands between the curly braces are run in order until a return statement is found.

dbSyncOn ( ) and dbSyncRate ( 60 ) Edit

Main articles: dbSyncOn and dbSyncRate
dbSyncOn tells windows that it is now in control of the monitor refresh. This means frame rates in your game will be more accurate. The dbSyncRate command tells the computer that it should try and refresh the monitor at around 60 frames per second.

dbMakeObjectCube ( 1, 1) Edit

Main article: dbMakeObjectCube
I think what this command does is self explanatory, but the first number is an integer which allows you to control other aspects of this object. The second is the width of the cube.

dbPositionCamera ( 10, 10, -20 ) Edit

Main article: dbPositionCamera
This command positions the default camera in 3D space. The numbers are floating point values, and the first is X, second is Y and third is Z.

while ( LoopGDK ( ) ) Edit

This is the start of the GDK loop. All the commands within this are run 60 times a second until the program is exited. The commands after this only run just before the program is ended.

dbMoveObject( 1, 0.5 ) Edit

Main article: dbMoveObject
In DarkGDK every object has a "forwards" direction, and this command tells an object to move in this way. The first number tells the program which object it is about, and we set the cube as object 1 earlier. The second is a floating point value saying how much the move the object forward by.

dbSync ( ) Edit

Main article: dbSync
This is your program's most important function. It tells the screen to update its contents. This should really only occur once within your loop.

dbDeleteObject ( 1 ) Edit

This command will remove object 1 (in this case the box) from memory. If you wish to bring the box back, it must be created again!

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.