/* ISU WHEEL OF FORTUNE project */ #include #include #include #include #include #include #include #include #include #include #include #define VGA256 0x13 #define TEXT 0x03 char far *videoBuffer = (char far *) 0xA0000000L; void setMode (int mode) { asm { mov ax, mode int 0x10 } } void putPixel (int x, int y, int color) { videoBuffer [((y<<8) + (y<<6)) + x] = (unsigned char) color; } void colorScr (int color) { _fmemset (videoBuffer, color, 64000L); } void Line (int x1, int y1, int x2, int y2, int color); void Oval(int x0, int y0, int a, int b, int color); int main () { clrscr (); //setMode (VGA256); setMode (TEXT); int numplayers, go=1; char *playername[3] = {" ", " ", " "}; int player1[3] = {0,0,0}, player2[3] = {0,0,0}, player3[3]= {0,0,0}; printf("\n\n\n\t\t\tWHEEL OF FORTUNE\n\n\n\t\t\tAlfa Vertion 1.3"); printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n"); printf("\nAny ties go to the lower number player.\nHit any key to continue, when weighting."); getch(); while (go != 0) { clrscr(); printf("\n\n\nHow many players do you want. (1 - 3)? "); scanf("%d", &numplayers); numplayers -= 1; fflush(stdin); if (numplayers == 0) { printf("\nENTER in you name player1.\n"); gets(playername[0]); playername[1] = " "; playername[2] = " "; printf("\nLets start the game!"); getch(); go = 0; } else if (numplayers == 1) { printf("\nENTER in you name player1.\n"); gets(playername[0]); printf("\nENTER in you name player2.\n"); gets(playername[1]); playername[2] = " "; printf("\nLets start the game!"); getch(); go = 0; } else if (numplayers == 2) { printf("\nENTER in you name player1.\n"); gets(playername[0]); printf("\nENTER in you name player2.\n"); gets(playername[1]); printf("\nENTER in you name player3.\n"); gets(playername[2]); printf("\nLets start the game!"); getch(); go = 0; } else { printf("That is incorrect!"); getch(); go = 1; } } fflush(stdin); randomize(); int strt; strt = random(numplayers); clrscr(); printf("\n%s starts.", playername[strt]); getch(); int what,spin; char *phrase1[] = {"DESK TOP COMPUTER","MANUFACTURED GOODS","AUTOMOBILE","TRANSFORMATION","COLOURS OF THE RAINBOW"}; char *phrase2[] = {"BACK SEAT OF A CAR","PROBABILITY OF SUCCESS","TRY TO TAKE OVER THE WORLD","PLOP PLOP FIZZ FIZZ OH WHAT A RELIEF IT IS"}; char *phrase3[] = {"GAME SHOW HOST","NEIGHBOR","BARBARIAN","SCIENTIST"}; char *answer1[] = {" "," "," "," "," "}; char *answer2[] = {" "," "," "," "}; char *answer3[] = {" "," "," "," "}; char noletter[20]; int goes1=1,flag=0,flag2=0,numletters=0,goes2=1,goes3=1,test=1; /* phrase 1 */ for (int a=0; a<26; a++) { noletter[a] = ' '; } int aa = 0; randomize(); int pn = random(sizeof(phrase1)/2); while (goes1 != 0) { for (int a=0; a 0) { clrscr(); printf("\nThere are only vowels left."); getch(); } if (flag == strlen(phrase1[pn])) { clrscr(); printf("\n\n\n"); printf("\nCongradgulations, You won!"); if (player1[strt] < 250) { player1[strt] = 250; printf("\n%s, you get $ %d.", playername[strt], player1[strt]); getch(); } else { printf("\n%s, you get $ %d.", playername[strt], player1[strt]); getch(); } printf("\nOn to Round Two."); getch(); if (strt == 2) strt = 0; else if (numplayers == 0) strt = 0; else if (numplayers == 1) { if (strt == 1) strt = 0; else strt += 1; } else strt += 1; int strt2 = strt; if (strt2 == 2) strt2 = 0; else if (numplayers == 0) strt2 = 0; else if (numplayers == 1) { if (strt2 == 1) strt2 = 0; else strt2 += 1; } else strt2 += 1; if (numplayers == 1) { player1[strt] = 0; } else if (numplayers == 2) { player1[strt] = 0; player1[strt2] = 0; } goes1 = 0; } clrscr(); printf("\n%s's turn.", playername[strt]); printf("\nYour score is %d.", player1[strt]); printf("\n%s",answer1[pn]); printf("\nTHING(S)"); printf("\n\nPress:\n1. Spin\n2. Buy a Vowel ($ 250)\n3. Solve\n4. Exit"); printf("\n\nEnter in a number. "); scanf("%d", &what); fflush(stdin); if (what == 1) { randomize(); printf ("\n"); clrscr(); int amount,strength; char bankrupt[] = "BANKRUPT"; char jackpot[] = "JACKPOT"; go = 1; while (go != 0) { clrscr(); printf("\nPower 5 - 10."); printf("\nHow much power would you like to spin the wheel? "); scanf("%d", &strength); fflush(stdin); if (strength < 5 || strength > 10) { printf("\nThat is incorrect."); getch(); } else { go = 0; } } strength *= 2; clrscr(); for (int a=0; a= 1) { if (num == 1) { printf("\nThere is %d %c.", num, letter); player1[strt] += amount; } else if (num > 1) { printf("\nThere are %d %c's.", num, letter); player1[strt] += amount*num; } } printf("\n%s", answer1[pn]); getch(); flag=0; for(a=0; a= 250) { player1[strt] -= 250; clrscr(); char vowel; printf("\n%s, your score is %d.", playername[strt], player1[strt]); printf("\n%s", answer1[pn]); printf ("\nOther letters used are : "); for (int q=0; q 0) { if (num == 1) { printf("\nThere is %d %c.", num, vowel); } else if (num > 1) { printf("\nThere are %d %c's.", num, vowel); } } if (flag >= strlen(phrase1[pn])) { noletter[aa] = vowel; aa += 1; printf("\nSorry, no %c's.", vowel); if (strt == 2) strt = 0; else if (numplayers == 0) strt = 0; else if (numplayers == 1) { if (strt == 1) strt = 0; else strt += 1; } else strt += 1; } printf("\n%s ", answer1[pn]); getch(); flag=0; for(int a=0; a 0) { clrscr(); printf("\nThere are only vowels left."); getch(); } if (flag == strlen(phrase2[pn])) { clrscr(); printf("\n\n\n"); printf("\nCongradgulations, You won!"); if (player2[strt] < 250) { player2[strt] = 250; printf("\n%s, you get $ %d.", playername[strt], player2[strt]); getch(); } else { printf("\n%s, you get $ %d.", playername[strt], player2[strt]); getch(); } printf("\nTo the Final Round."); getch(); if (strt == 2) strt = 0; else if (numplayers == 0) strt = 0; else if (numplayers == 1) { if (strt == 1) strt = 0; else strt += 1; } else strt += 1; int strt2 = strt; if (strt2 == 2) strt2 = 0; else if (numplayers == 0) strt2 = 0; else if (numplayers == 1) { if (strt2 == 1) strt2 = 0; else strt2 += 1; } else strt2 += 1; if (numplayers == 1) { player2[strt] = 0; } else if (numplayers == 2) { player2[strt] = 0; player2[strt2] = 0; } goes2 = 0; } clrscr(); printf("\n%s's turn.", playername[strt]); printf("\nYour score is %d.", player2[strt]); printf("\n%s",answer2[pn]); printf("\nPHRASE"); printf("\n\n1. Spin\n2. Buy a Vowel\n3. Solve\n4. Exit"); printf("\n\nEnter in a number. "); scanf("%d", &what); fflush(stdin); if (what == 1) { randomize(); printf ("\n"); clrscr(); int amount,strength; char bankrupt[] = "BANKRUPT"; char jackpot[] = "JACKPOT"; go = 1; while (go != 0) { clrscr(); printf("\nPower 5 - 10."); printf("\nHow much power would you like to spin the wheel? "); scanf("%d", &strength); fflush(stdin); if (strength < 5 || strength > 10) { printf("\nThat is incorrect."); getch(); } else { go = 0; } } strength *= 2; clrscr(); for (int a=0; a= 1) { if (num == 1) { printf("\nThere is %d %c.", num, letter); player2[strt] += amount; } else if (num > 1) { printf("\nThere are %d %c's.", num, letter); player2[strt] += amount*num; } } printf("\n%s", answer2[pn]); getch(); flag=0; for(a=0; a= 250) { player2[strt] -= 250; clrscr(); char vowel; printf("\n%s, your score is %d.", playername[strt], player2[strt]); printf("\n%s", answer2[pn]); printf ("\nOther letters used are : "); for (int q=0; q 0) { if (num == 1) { printf("\nThere is %d %c.", num, vowel); } else if (num > 1) { printf("\nThere are %d %c's.", num, vowel); } } if (flag >= strlen(phrase2[pn])) { noletter[aa] = vowel; aa += 1; printf("\nSorry, no %c's.", vowel); if (strt == 2) strt = 0; else if (numplayers == 0) strt = 0; else if (numplayers == 1) { if (strt == 1) strt = 0; else strt += 1; } else strt += 1; } printf("\n%s ", answer2[pn]); getch(); flag=0; for(int a=0; a 0) { clrscr(); printf("\nThere are only vowels left."); getch(); } if (flag == strlen(phrase3[pn])) { clrscr(); printf("\n\n\n"); printf("\nCongradgulations, You won!"); if (player3[strt] < 250) { player3[strt] = 250; printf("\n%s, you get $ %d.", playername[strt], player3[strt]); getch(); } else { printf("\n%s, you get $ %d.", playername[strt], player3[strt]); getch(); } printf("\nThanks for playing."); if (strt == 2) strt = 0; else if (numplayers == 0) strt = 0; else if (numplayers == 1) { if (strt == 1) strt = 0; else strt += 1; } else strt += 1; int strt2 = strt; if (strt2 == 2) strt2 = 0; else if (numplayers == 0) strt2 = 0; else if (numplayers == 1) { if (strt2 == 1) strt2 = 0; else strt2 += 1; } else strt2 += 1; if (numplayers == 1) { player3[strt] = 0; } else if (numplayers == 2) { player3[strt] = 0; player3[strt2] = 0; } goes3=0; test=1; getch(); } clrscr(); printf("\n%s's turn.", playername[strt]); printf("\nYour score is %d.", player3[strt]); printf("\n%s",answer3[pn]); printf("\nPERSON"); printf("\n\n1. Spin\n2. Buy a Vowel\n3. Solve\n4. Exit"); printf("\n\nEnter in a number. "); scanf("%d", &what); fflush(stdin); if (what == 1) { randomize(); printf ("\n"); clrscr(); int amount,strength; char bankrupt[] = "BANKRUPT"; char jackpot[] = "JACKPOT"; go = 1; while (go != 0) { clrscr(); printf("\nPower 5 - 10."); printf("\nHow much power would you like to spin the wheel? "); scanf("%d", &strength); fflush(stdin); if (strength < 5 || strength > 10) { printf("\nThat is incorrect."); getch(); } else { go = 0; } } strength *= 2; clrscr(); for (int a=0; a= 1) { if (num == 1) { printf("\nThere is %d %c.", num, letter); player3[strt] += amount; } else if (num > 1) { printf("\nThere are %d %c's.", num, letter); player3[strt] += amount*num; } } printf("\n%s", answer3[pn]); getch(); flag=0; for(a=0; a= 250) { player3[strt] -= 250; clrscr(); char vowel; printf("\n%s, your score is %d.", playername[strt], player3[strt]); printf("\n%s", answer3[pn]); printf ("\nOther letters used are : "); for (int q=0; q 0) { if (num == 1) { printf("\nThere is %d %c.", num, vowel); } else if (num > 1) { printf("\nThere are %d %c's.", num, vowel); } } if (flag >= strlen(phrase3[pn])) { noletter[aa] = vowel; aa += 1; printf("\nSorry, no %c's.", vowel); if (strt == 2) strt = 0; else if (numplayers == 0) strt = 0; else if (numplayers == 1) { if (strt == 1) strt = 0; else strt += 1; } else strt += 1; } printf("\n%s ", answer3[pn]); getch(); flag=0; for(int a=0; a= scores[1] && scores[0] >= scores[2]) { printf("\n\n%s is going on to the bonus round.", playername[0]); num=1; } else if (scores[1] > scores[0] && scores[1] >= scores[2]) { printf("\n\n%s is going on to the bonus round.",playername[1]); num=2; } else if (scores[2] > scores[0] && scores[2] > scores[1]) { printf("\n\n%s is going on to the bonus round.",playername[2]); num=3; } else printf("\nYou got something wrong!."); getch(); clrscr(); char *bonus[] = {"ELEVATOR","CERTIFICATE","LABYRINTH","XYLOPHONE"}; char *solveb[] = {" "," "," "," "}; randomize(); pn = random(sizeof(bonus)/2); int flag=0; char letter; letter = 'R'; for(int a=0; a=0) { xInc = 1; } else { xInc = -1; dx = -dx; } if (dy>=0) { yInc = 320; } else { yInc = -320; dy = -dy; } if (dx>dy) { for (i=0; i<=dx; i++) { *vBptr = color; error += dy; if (error>dx) { error -= dx; vBptr += yInc; } vBptr += xInc; } } else { for (i=0; i<=dy; i++) { *vBptr = color; error += dx; if (error>0) { error -= dy; vBptr += xInc; } vBptr += yInc; } } } void Oval(int x0, int y0, int a, int b, int color) { int x, y; // midpoint algorithm is a long aSquared, twoAsquared; // variation on Bresenham long bSquared, twoBsquared; long d, dx, dy; x = 0; y = b; aSquared = a * a; twoAsquared = 2 * aSquared; bSquared = b * b; twoBsquared = 2 * bSquared; // initial excess distance d d = bSquared - aSquared * b + aSquared / 4L; dx = 0; // initial run and rise dy = twoAsquared * b; // magnitudes dx and dy while (dx < dy) { // slow slope > -1 putPixel(x0+x, y0+y, color); putPixel(x0+x, y0-y, color); putPixel(x0-x, y0+y, color); putPixel(x0-x, y0-y, color); if (d > 0) { // midpoint is outside --y; // go down one line dy -= twoAsquared; d -= dy; ++x; dx += twoBsquared; d += bSquared + dx; } else { ++x; // midpoint is inside dx += twoBsquared; d += bSquared + dx; } } // reset d for fast slope d += (3L * (aSquared - bSquared) / 2L - (dx + dy)) / 2L; while (y >= 0) { // fast slope < -1 putPixel(x0+x, y0+y, color); putPixel(x0+x, y0-y, color); putPixel(x0-x, y0+y, color); putPixel(x0-x, y0-y, color); if (d < 0) { // midpoint is outside ++x; dx += twoBsquared; d += dx; } --y; // midpoint is inside dy -= twoAsquared; d += aSquared - dy; } }