Just wanted to throw out a thank you to the DB team for the release of it free with Visual C++ 2008. It is very nice to be able to use it. Such a great improvement over classic DB =)
Thanks again,
Bishop
*edit* Just playin around with it ^_^ PONG!
// Dark GDK - The Game Creators - www.thegamecreators.com
// the wizard has created a very simple project that uses Dark GDK
// it contains the basic code for a GDK application
// whenever using Dark GDK you must ensure you include the header file
#include "DarkGDK.h"
#include "string.h"
// struct for ball
struct ball
{
public:
int up, down, left, right;
int objectNumber;
float speed;
int posx, posy;
};
// the main entry point for the application is this function
void DarkGDK ( void )
{
// turn on sync rate and set maximum rate to 60 fps
dbSyncOn ( );
dbSyncRate ( 60 );
dbSetWindowOff ( );
dbHideMouse ( );
// make ball
dbMakeObjectCube ( 1, 1);
dbColorObject (1, dbRGB( 255, 0, 0 ) );
// make paddle
dbMakeObjectBox ( 2, 2, 6, 2 );
dbColorObject ( 2, dbRGB( 0, 0, 255 ) );
dbPositionObject ( 2, -40, 0, 0 );
// make wall
dbMakeObjectBox ( 3, 2, 50, 2 );
dbColorObject ( 3, dbRGB( 0, 255, 0 ) );
dbPositionObject ( 3, 40, 0, 0 );
dbMakeObjectBox ( 4, 79, 2, 2 );
dbColorObject ( 4, dbRGB( 0, 255, 0 ) );
dbPositionObject ( 4, 0, 25, 0 );
dbMakeObjectBox ( 5, 79, 2, 2 );
dbColorObject ( 5, dbRGB( 0, 255, 0 ) );
dbPositionObject ( 5, 0, -25, 0 );
// Ball
ball gameBall;
gameBall.down = 1;
gameBall.right = 1;
gameBall.objectNumber = 1;
gameBall.speed = .3;
// position camera
dbPositionCamera ( 0, 8, -60 );
// our main loop
while ( LoopGDK ( ) )
{
// backdrop
dbColorBackdrop ( 0 );
// paddle movement
if( dbUpKey ( ) == 1 )
{
dbMoveObjectUp ( 2, 1 );
}
if( dbDownKey ( ) == 1 )
{
dbMoveObjectDown ( 2, 1 );
}
// move ball
if( gameBall.right == 1 )
dbMoveObjectRight ( 1, gameBall.speed);
if( gameBall.left == 1)
dbMoveObjectLeft ( 1, gameBall.speed);
if( gameBall.up == 1)
dbMoveObjectUp ( 1, gameBall.speed);
if( gameBall.down == 1)
dbMoveObjectDown ( 1, gameBall.speed);
// collision
if( dbObjectCollision ( 1, 5 ) )
{
gameBall.up = 1;
gameBall.down = 0;
}
if( dbObjectCollision ( 1, 3 ) )
{
gameBall.right = 0;
gameBall.left = 1;
}
if( dbObjectCollision ( 1, 4 ) )
{
gameBall.up = 0;
gameBall.down = 1;
}
if( dbObjectCollision ( 1, 2 ) )
{
gameBall.left = 0;
gameBall.right = 1;
gameBall.speed += .05;
}
// print to screen
// update the screen
dbSync ( );
}
// return back to windows
return;
}
Tux is my guildmaster.