Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / Coin Flip help

Author
Message
LeoParkour
11
Years of Service
User Offline
Joined: 31st Mar 2013
Location:
Posted: 31st Mar 2013 21:09
So anyone on. I'm not receiving any errors for this but can't seem to even get pass the "press any key to continue" screen

// include the Dark GDK header file (http://forum.thegamecreators.com/?m=forum_read&i=22)
#include "DarkGDK.h"

//Global Variables
int number = -1;
const int HEADS = 0;
const int TAILS = 1;
const int spriteFlip = 3;
const int coinFlipSprite= 3;
const int headsSprite = 1;
const int tailsSprite = 1;
const int coinX = 320;
const int coinY = 240;

//Function prototypes
void setUp();
void coinToss();

// main entry point for the application
void DarkGDK ( void )
{
dbSetWindowTitle("Coin Toss");

setUp(); // The setup function.
coinToss(); //The coinToss function

dbPrint("Welcome to the coin toss. Press any key to start the game!");

//Waits for the user to press any key.
dbWaitKey();

coinToss(); //The coinToss function


// our main game loop
while ( LoopGDK ( ) )
{
//LOOP CODE HERE //


// update the contents of the screen
dbSync ( );
}

// return back to Windows
return;
}

void setUp()
{
// Load the images.
dbLoadImage("Heads.bmp", HEADS);
dbLoadImage("Tails.bmp", TAILS);

//Constant for the refresh rate.
const int REFRESH_RATE = 60;

//Seed the random number generator.
dbRandomize(dbTimer() );

//Disable auto refresh and set the refresh rate.
dbSyncOn();
dbSyncRate(REFRESH_RATE);
}


void coinToss()
{
number = dbRND(1);
}
granarout
11
Years of Service
User Offline
Joined: 2nd Jan 2013
Location:
Posted: 2nd Apr 2013 15:18
It actually does get past the dbWaitKey() function, it's just that because no sprites/3d is drawn during the dbSync(), DGDK doesn't clear the screen every refresh, so it is keeping "Welcome to the coin toss. Press any key to start the game!" on the backbuffer.

Use dbCLS() to clear the screen during the game loop

Login to post a reply

Server time is: 2024-11-18 21:31:06
Your offset time is: 2024-11-18 21:31:06