Hello Everyone,
I am fairly new at this. This program basically is just a program that changes the color of the screen. Right now the program runs well but when the numbers repeat from the random number generator my screen has a delay of an extra half a second.
I have been trying to figure out how to set a variable in order to capture the random number and then put it into and if () else () statement. There are only four possible outcomes 0 - 3 in the RNG.
#include "DarkGDK.h"
void DarkGDK()
{
//Set Window Title
dbSetWindowTitle("Color Array");
//Color Constants
const DWORD RED = dbRGB(255, 0, 0);
const DWORD GREEN = dbRGB(0, 255, 0);
const DWORD BLUE = dbRGB(0, 0, 255);
const DWORD MAGENTA = dbRGB(255, 0, 255);
//Constant for time delay (half a second)
const int DELAY = 500;
//Constant for the array size
const int SIZE = 4;
//Array of colors
DWORD colors[SIZE] = { RED, GREEN, BLUE, MAGENTA };
//Variable to use as an array index
int index;
int selected;
//Seed the random number generator.
dbRandomize( dbTimer() );
// Repeatedly clear the screen with random colors.
while ( LoopGDK() )
{
//Calculate random number.
index = dbRND(SIZE - 1);
//Clear the creen to a random color.
dbCLS( colors[index] );
//Wait.
dbWait(DELAY);
}
}
If was thinking once I was able to get the variable set to captured the if() else() statement would look like this.
int capture; //variable for the random value between 0 - 3,
if(capture == index)
{
if(capture == 3)
{
capture--;
}
else
{
capture++;
}
}
any help would be appreciated. Thank you.
Carlos