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 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150
|
#include<stdio.h>
#include<windows.h>
void error(char *choice);
void welcome(char gamechoice);
void gameone(char *gamechoice);
void gametwo(char *gamechoice);
void gamethree(char *gamechoice);
int main()
{
char choice, gamechoice;
// Changes text foreground and background colour properties
SetConsoleTextAttribute( GetStdHandle( STD_OUTPUT_HANDLE ), 777);
system("cls");
printf("Would you like to execute this program? y/n \n");
scanf("%s", &choice);
_flushall();
// Calls welcome page/function
if (choice == 'y' || choice == 'Y')
{
welcome(gamechoice);
}
// terminate the program
else if (choice == 'n' || choice == 'N')
{
system("cls");
printf("zZzzZZzzZZz");
sleep(500);
goto END;
}
// Calls error function
else if (choice != 'n' && choice != 'y' && choice != 'N' && choice != 'Y')
{
error(&choice);
}
// Insert C code after this marker
END:
return 0;
}
void error(char *choice)
{
// Displays error message in window
system("MSG * Error: Cannot read input!");
system("cls");
sleep(1000);
// Recalls int main() so correct input can be achieved
main();
}
void welcome(char gamechoice)
{
system("cls");
printf("%*s### ### ###### ## ###### ###### #### #### ######\n", 10);
printf("%*s### ### ###### ## ###### ###### ## ## ######\n", 10);
printf("%*s### ### ## ## ## ## ## ### ### ##\n", 10);
printf("%*s### # ### ###### ## ## ## ## ## # # ## ######\n", 10);
printf("%*s### # ### ###### ## ## ## ## ## # ## ######\n", 10);
printf("%*s ## ### ## ## ## ## ## ## ## ## ##\n", 10);
printf("%*s ### ### ###### ###### ###### ###### ## ## ######\n", 10);
printf("%*s # # ###### ###### ###### ###### #### #### ######\n", 10);
printf("\n\n");
sleep(1000);
// Displays option box in contrasting background colour
printf("%*s", 27);
SetConsoleTextAttribute( GetStdHandle( STD_OUTPUT_HANDLE ), 377);
printf("##===================##\n");
SetConsoleTextAttribute( GetStdHandle( STD_OUTPUT_HANDLE ), 777);
printf("%*s", 27);
SetConsoleTextAttribute( GetStdHandle( STD_OUTPUT_HANDLE ), 377);
printf("|| ||\n");
SetConsoleTextAttribute( GetStdHandle( STD_OUTPUT_HANDLE ), 777);
printf("%*s", 27);
SetConsoleTextAttribute( GetStdHandle( STD_OUTPUT_HANDLE ), 377);
printf("||1. Game A ||\n");
SetConsoleTextAttribute( GetStdHandle( STD_OUTPUT_HANDLE ), 777);
printf("%*s", 27);
SetConsoleTextAttribute( GetStdHandle( STD_OUTPUT_HANDLE ), 377);
printf("||2. Game B ||\n");
SetConsoleTextAttribute( GetStdHandle( STD_OUTPUT_HANDLE ), 777);
printf("%*s", 27);
SetConsoleTextAttribute( GetStdHandle( STD_OUTPUT_HANDLE ), 377);
printf("||3. Game C ||\n");
SetConsoleTextAttribute( GetStdHandle( STD_OUTPUT_HANDLE ), 777);
printf("%*s", 27);
SetConsoleTextAttribute( GetStdHandle( STD_OUTPUT_HANDLE ), 377);
printf("||4. Exit ||\n");
SetConsoleTextAttribute( GetStdHandle( STD_OUTPUT_HANDLE ), 777);
printf("%*s", 27);
SetConsoleTextAttribute( GetStdHandle( STD_OUTPUT_HANDLE ), 377);
printf("|| ||\n");
SetConsoleTextAttribute( GetStdHandle( STD_OUTPUT_HANDLE ), 777);
printf("%*s", 27);
SetConsoleTextAttribute( GetStdHandle( STD_OUTPUT_HANDLE ), 377);
printf("##===================##\n\n");
SetConsoleTextAttribute( GetStdHandle( STD_OUTPUT_HANDLE ), 777);
printf("What would you like to do?\n");
scanf("%s", &gamechoice);
_flushall();
if (gamechoice == 1)
{
gameone(&gamechoice);
}
else if (gamechoice == 2)
{
gametwo(&gamechoice);
}
else if (gamechoice == 3)
{
gamethree(&gamechoice);
}
}
void gameone(char *gamechoice)
{
system("cls");
printf("Game One Under Construction!");
system("pause");
}
void gametwo(char *gamechoice)
{
system("cls");
printf("Game Two Under Construction!");
system("pause");
}
void gamethree(char *gamechoice)
{
system("cls");
printf("Game Three Under Construction!");
system("pause");
}
|