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 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227
|
/*Halloween program(not finished)
*/
#include<iostream>
#include<iomanip>
#include<string>
#include <cctype> // <--- Added for "std::tolower()" and "std::toupper()".
//#include<algorithm>
#include<stdlib.h>
#include<windows.h>
#undef max // <--- This is need when windows is included and must be done after "windows.h" and before you incllude "limits".
#include <limits> // <--- Added.
#define CLS cls() // <--- In the program the capital letters will be replaced with the function call. You add the semi-colon.
using namespace std;
void SetColor(int forground, int background);
void cls();
int main()
{
//declare variables
char type{}; // <--- Changed. The empty {}s do the same thing.
char choice{}; // <--- Changed since "list" is nolonger used. Used in part of the program not here.
//enter input items
//cout << "List of pictures(Y or N): ";
//cin >> list;
//list = std::toupper(list);
//if (list != 'Y' && list != 'N')
// cout << "Please enter Y(es) or N(o). ";
//else
//{
// if (list == 'Y')
CLS;
cout << "\n (w)itch" << endl << " (p)umpkin" << endl << " (g)host" << endl; // <--- Changed.
//}
cout << " Enter choice: "; // <--- Changed.
cin >> type;
type = std::tolower(type); // <--- Added. Makes sure what is entered ends up a lower case letter.
//display
if (type != 'w' && type != 'p' && type != 'g')
cout << "Please enter (w)itch, (p)umpkin or (g)host" << endl; // <--- Changed.
else
{
CLS;
std::cout << "\n\n";
switch (type)
{
case 'w':
SetColor(10, 0); // <--- Parameters are forground and background. Green on black.
cout << " ( '' ) " << endl;
cout << " ( _ * " << endl;
cout << " * ( / \ ___ " << endl;
cout << " " " _/ / " << endl;
cout << " ( * ) ___/ | " << endl;
cout << " ) '' _ o)'-./__ " << endl;
cout << " * _ ) (_, . $$$ " << endl;
cout << " ( ) __ __ 7_ $$$$ " << endl;
cout << " ( : { _) '--- $\ " << endl;
cout << " ______'___//__\ ____, \ " << endl;
cout << " ) ( \_/ _____\_ " << endl;
cout << " .' \ \------''. " << endl;
cout << " |=' '=| | ) " << endl;
cout << " | | | . _/ " << endl;
cout << " \ (. ) , / /__I_____\ " << endl;
cout << " '._/_)_(\__.' (__,(__,_] " << endl;
cout << " @---()_.'---@ " << endl;
break;
case 'p':
SetColor(10, 0);
cout << " ,---._" << endl;
cout << " ,~~,-._ `._ " << endl;
cout << " v'~ `-. `. " << endl;
cout << " _,- ~. \ " << endl;
cout << " .' ,--`. `\_ " << endl;
cout << " V-'~ ,'~~~`-. `-. " << endl;
cout << " ___ /_/~~~) ` `. `._ " << endl;
cout << " ____,---' ; V `.__ `--, `; " << endl;
cout << " `-._ ; `. ____) : " << endl;
cout << " `.; ; .' ,' _ | " << endl;
cout << " ; | ; ,';'~~~`--' `; : " << endl;
cout << " ,': .-' `,' __ __ : | " << endl;
cout << " )_ `-, ___ __ (__:__) ; ; " << endl;
cout << " _,---. \___,'` ~`---; `-. ||| ; ; " << endl;
cout << " _,-/ :; ! ` `| `-. |~~~~| ; : " << endl;
cout << " _,-' /~ .,' ; !! `.. ``. `. : ; | : " << endl;
cout << " ,' ,-' .; `; !! _,'-' ,--._ ====\__/===: `. " << endl;
cout << " .' ,-' ,--. ~~`-. !! ~ ,' ` `./ \ | | " << endl;
cout << " .' :; ,' \ !: . ;--.__ `;. |. ~.| : ; " << endl;
cout << " .' ,; ' ,-'~~`-. ,! ;-' #; `;. \____/ : `. " << endl;
cout << " .' ,; /__ `-._,'!!( _(0'~~`-' `;. `. ; ; " << endl;
cout << " .' ,; ,' `---._(0)) !! ~ _,-, `; `. ; : " << endl;
cout << " ; ,; ,' ;;-.__,-._~~~ !!__,--::::|. `;: : `; ) " << endl;
cout << " ; :| ,' ;/;;; :::;;;;----'|:: |::;\/#. `; | ) ; " << endl;
cout << " : |: ,' ,' :/ :;; \/))):;;::/ ::' ##: ;; ; ; | " << endl;
cout << " | :| :; : `' \/ \/ `' `' ##; ; .' ,' ; " << endl;
cout << " : |; || .' ;\. ____ __,--._ ##; ;' .'--' ; " << endl;
cout << " _,--`. `. :: `./; /\/;:;,-' `-. `--.__ .'~ ,'~ " << endl;
cout << " / ;. `; ``. :::;\;.-'~~`./~~\/\ .. _ ::: --. ' ,-'~ " << endl;
cout << " / . `. `; ` ~~~ ;~ ~~~~~~`--.__~~`-. ::: ) ~ " << endl;
cout << "/' ;`--`. `. `. :; `; ; `---`._ ,' " << endl;
cout << "`. \/ `-.` `_,_ `:,-'-. `. :_,_ ; `--' " << endl;
cout << " `. `. ` (___)-: ( ) :--,-'- -(___),'~~~`. " << endl;
cout << " {_ `. `.___.' ( ; ;) :((:)): " << endl;
cout << " `. ` `--' `.___.' " << endl;
cout << " `. `. ;;:::; " << endl;
cout << " `- `. ;;;. .; " << endl;
cout << " `-. `.__ \\;;; - ;; // " << endl;
cout << " `. ` `--..___ \\,--v-, // " << endl;
cout << " `--._ ~~~~~`)____(// " << endl;
cout << " ) ~~ ~~~~~~; " << endl;
cout << " `. ~~ ------; " << endl;
cout << " `.~~_ ______,' " << endl;
cout << " `. `.--';: |: " << endl;
cout << " ; `. Cc; Cc " << endl;
cout << " `. ; __ " << endl;
cout << " `. `-' ~\ " << endl;
cout << " `-.__,--'~ " << endl;
break;
case 'g':
SetColor(10, 0);
cout << " .---. " << endl;
cout << " / \ " << endl;
cout << "---- _ | O O | _ --- " << endl;
cout << "\ ~-. `. .' .-~ / " << endl;
cout << " \ ~-_> <_-~ / " << endl;
cout << " \ / " << endl;
cout << " \ / " << endl;
cout << " \ / " << endl;
cout << " \ / " << endl;
cout << " \ / " << endl;
cout << " \ / " << endl;
cout << " \ \ " << endl;
cout << " \ \ " << endl;
cout << " \ \ " << endl;
cout << " \ \ " << endl;
cout << " \ l " << endl;
cout << " \ / " << endl;
cout << " V " << endl;
}
SetColor(7, 0); // <--- White on black.
// <--- Better to use than "system("pause");"
// <--- Used mostly for testing in Debug mode. Removed if compiled for release.
// <--- Used to keep the console window open in Visual Studio Debug mode.
// The next line may not be needid. If you have to press enter to see the prompt it is not needed.
std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n'); // <--- Requires header file <limits>.
std::cout << "\n\n Press Enter to continue: ";
std::cin.get();
//system("pause");
return 0;
}
void SetColor(int forground, int background)
{
WORD consoleColor;
HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
CONSOLE_SCREEN_BUFFER_INFO csbi;
if (GetConsoleScreenBufferInfo(hStdOut, &csbi))
{
consoleColor = (forground + (background * 16));
SetConsoleTextAttribute(hStdOut, consoleColor);
}
} // End SetColor()
// <--- This goes with the "cls" function and needs to be here before the function.
#define PERR(bSuccess, api){if(!(bSuccess)) printf("%s:Error %d from %s on line %d\n", \
__FILE__, GetLastError(), api, __LINE__);}
void cls()
{
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
COORD coordScreen = { 0, 0 }; /* here's where we'll home the
cursor */
BOOL bSuccess;
DWORD cCharsWritten;
CONSOLE_SCREEN_BUFFER_INFO csbi; /* to get buffer info */
DWORD dwConSize; /* number of character cells in
the current buffer */
/* get the number of character cells in the current buffer */
bSuccess = GetConsoleScreenBufferInfo(hConsole, &csbi);
PERR(bSuccess, "GetConsoleScreenBufferInfo");
dwConSize = csbi.dwSize.X * csbi.dwSize.Y;
/* fill the entire screen with blanks */
bSuccess = FillConsoleOutputCharacter(hConsole, (TCHAR) ' ',
dwConSize, coordScreen, &cCharsWritten);
PERR(bSuccess, "FillConsoleOutputCharacter");
/* get the current text attribute */
bSuccess = GetConsoleScreenBufferInfo(hConsole, &csbi);
PERR(bSuccess, "ConsoleScreenBufferInfo");
/* now set the buffer's attributes accordingly */
bSuccess = FillConsoleOutputAttribute(hConsole, csbi.wAttributes,
dwConSize, coordScreen, &cCharsWritten);
PERR(bSuccess, "FillConsoleOutputAttribute");
/* put the cursor at (0, 0) */
bSuccess = SetConsoleCursorPosition(hConsole, coordScreen);
PERR(bSuccess, "SetConsoleCursorPosition");
return;
} // End CLS
|