Hello--I'm new to using the Dark GDK (and C++ in general). I've had some experience programming simple games in Java, so I'm currently trying to reproduce those games with the Dark GDK. At the moment, however, I cannot even get a rectangle to move across the screen. Here is my code:
#include "DarkGDK.h"
void gameUpdate();
const int PWIDTH = 800;
const int PHEIGHT = 600;
int x = 0;
int y = 0;
void DarkGDK ( void ){
dbSetWindowSize(PWIDTH, PHEIGHT);
dbSetDisplayMode (PWIDTH, PHEIGHT, 32);
dbSyncOn ( );
dbSyncRate ( 60 );
dbSetWindowPosition((GetSystemMetrics(SM_CXSCREEN) - PWIDTH)/2,(GetSystemMetrics(SM_CYSCREEN) - PHEIGHT)/2);
while ( LoopGDK ( ) ){
gameUpdate();
dbSync ( );
}
return;
}
void gameUpdate(){
dbCLS();
x++;
if (x == PWIDTH){
x = -100;
y += 100;
}
if(y == PHEIGHT) y = 0;
dbBox(x,y,(x+100),(y+100));
}
The call to dbCLS() does nothing, with the result that my box just expands to the right. After swapping some of the code around, I discovered that dbCLS seems to clear the background while dbBox draws to the foreground.
I then tried to simulate dbCLS with a call to dbBox(0,0,PWIDTH,PHEIGHT), but the background box drew once and then never again, while the other box continued to ooze across the screen. After fiddling with the numbers, I found that the background box would only draw and refresh properly if its dimensions were at least one pixel less than the window size.
The problem persists even if I take out the code to change the window size and resolution.
Could someone please point out the very basic thing I must be missing?