1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
|
#include <windows.h>
#include "general.h"
/*****************************************************************************/
int sort_function( const void *a, const void *b)
{
return( strcmp((char *)a,(char *)b) );
}
/*****************************************************************************/
void Randomize()
{
int iPtr;
/* Setup a random seed number from computer time */
srand(time(NULL));
/* Get random numbers 1 to 5 between 1 and 59 */
for (iPtr = 0; iPtr < 5; iPtr++) {
/* Check for numbers are the same. If so redo */
do {
iRand[iPtr] = ((rand() % 59) + 1);
} while (iRand[iPtr] == (iRand[0] || iRand[1] ||
iRand[2] || iRand[3] ||
iRand[4]));
}
// Sort the numbers
qsort(iRand, 5, sizeof(iRand[0]), sort_function);
// Do the powerball. 1 to 39
iRand[5] = ((rand() % 39) + 1);
// set up our timer
Timer_ID = SetTimer(hWnd , ID_TIMER_1, 500 , NULL);
iLevelAnimation = 0;
}
/*****************************************************************************/
void PrintOut()
{
switch(iStr_X) {
case 0:
SetAnimation(150, 40, iRand[0]);
break;
case 1:
SetAnimation(180, 40, iRand[1]);
break;
case 2:
SetAnimation(210, 40, iRand[2]);
break;
case 3:
SetAnimation(240, 40, iRand[3]);
break;
case 4:
SetAnimation(270, 40, iRand[4]);
break;
case 5:
// Convert random number to ascii string
strcpy(szMessage, "PowerBall: ");
iXpos = 10;
iYpos = 70;
// Print out
InvalidateRect(hWnd, NULL, NULL);
iStr_X++;
break;
case 6:
SetAnimation(150, 70, iRand[5]);
break;
case 7:
// Convert random number to ascii string
strcpy(szMessage, "*** GOOD LUCK ***");
iXpos = 85;
iYpos = 140;
// Print out
InvalidateRect(hWnd, NULL, NULL);
iStr_X++;
break;
default:
KillTimer(hWnd, ID_TIMER_1);
}
}
|