Hi, I'm back after a long time, I didn't have the time to continue trying to learn DB, but I decided to have another crack at it, but I've forgotton stuff.
Basically I'm trying to create the most simple game possible, Pong! Already after a couple of lines of code I'm having problems.
The bat which is drawn as a box, appears on the screen perfectly, but when I attempt to redraw it when the left key is pressed (For movement purposes) it just creates a long box along the movement path.
I tried dbCLS() inside the main loop, but that just prevents the box from being displayed at all.
Cheers
Scarface
// 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"
// Global Variables
const int BAT_SPEED = 10;
// 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 );
// Initilize Variables
int bat_1_pos_x = 270;
// our main loop
while ( LoopGDK( ) )
{
dbBox( bat_1_pos_x, 30, bat_1_pos_x + 100, 40 );
if (dbLeftKey( ))
{
bat_1_pos_x -= BAT_SPEED;
}
// update the screen
dbSync( );
}
// return back to windows
return;
}
- Scarface