PPD! There's been a murder!
Jun 18, 2008 at 6:31pm
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
|
#include <iostream>
using namespace std;
int main()
{
bool a = true;
int Kills = 0;
cout << "Hello World! My name is Mr. Jones! \n";
system("pause");
do{
cout << "DON'T PRESS MY KEYS! It hurts...\n";
system("pause");
cout << "Ouch!\n";
system("pause");
cout << "Auugh!\n";
system("pause");
cout << "Unngh...please stop...you there...system(\"pause\"), shut up...\n";
system("pause");
cout << "Oghh...*collapse*\n";
system("pause");
Kills++;
system("cls");
if(Kills == 1)
cout << "You there! Stop! PPD! Program Police Department! You have killed a person!\n";
else
cout << "You there! Stop! PPD! Program Police Department! You have killed " << Kills << " people!\n";
system("pause");
if(Kills == 3)
{
cout << "Hah! I am immune to key-pressing!\n";
a = false;
}
}while (a);
cout << "You have been captured and hanged. HAHAHAHA!\nPress ENTER to continue...";
cin.get();
return 0;
}
|
I know, system("pause") and ("cls") are no-nos, but without it, the program loses its hilarosity, so
NYEH!
Last edited on Jun 18, 2008 at 7:13pm
Jun 18, 2008 at 7:34pm
I still say
curses is a cleaner solution.
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
|
// ouch.cpp
#include <cctype>
#include <string>
#include <curses.h>
struct console_t
{
console_t()
{
initscr();
raw();
(void)noecho();
nonl();
intrflush( stdscr, FALSE );
(void)keypad( stdscr, TRUE );
curs_set( 0 );
}
~console_t()
{
endwin();
}
};
const char* messages[ 3 ] =
{
"Press the 'any' key...",
"\n\rAck! Not that one! Try again.",
"\n\rWoah! Watch it! Press the ANY key!"
};
int main()
{
using namespace std;
console_t console;
char keys[ 4 ];
for (int i = 0; i < 3; i++)
{
addstr( (char*)(::messages[ i ]) );
keys[ i ] = toupper( getch() );
}
keys[ 3 ] = '\0';
if (string( "ANY" ) == keys)
addstr( (char*)"\n\rFinally! Thank you.\n\r" );
else
addstr( (char*)"\n\rOh forget it!\n\r" );
move( 10, 0 );
addstr( (char*)"Press any key to quit. (Seriously this time.)" );
getch();
return 0;
}
// end ouch.cpp
|
Compiles on Win32, *nix, Mac OSX, Amiga, SNES, etc.
On my XP box using GCC:
g++ -Wall -pedantic -o ouch ouch.cpp -lpdcurses |
On linux using GCC:
g++ -Wall -pedantic -o ouch ouch.cpp -lncurses |
Enjoy!
Topic archived. No new replies allowed.