예제 #1
0
파일: main.c 프로젝트: jenya-meow/Viselica
int main()
{
    set_escdelay(0);
    setlocale(LC_ALL, "");
    initscr();
    char a;
    mvwprintw(stdscr, 1, (getmaxx(stdscr) - 18) / 2,
              "Добро пожаловать в\n");
    while (a != 'q' && a != 'Q' && a != 27) {
        hangman();
        keypad(stdscr, true);
        attron(A_REVERSE);
        mvwprintw(stdscr, getmaxy(stdscr) - 1, 0,
                  "Нажмите ENTER для начала, Q или ESC для выхода");
        attroff(A_REVERSE);
        cbreak();
        refresh();
        a = getch();
        if (a == '\n') {
            game();
        }
        clear();
    }
    keypad(stdscr, false);
    endwin();
    printf("Bye - bye!\n");
    return 0;
}
예제 #2
0
파일: main.c 프로젝트: byker93/First_repo
int main() {
	char secret[30];
	if (getWord( secret) != 0) {
		printf("Error with input file\n");
		return 0;
	}
	hangman( secret);
	return 0;
}
예제 #3
0
int main() {
    char choice[16];
    int seed;
    allocate(0x1000, 1, (void **)&state);
    if(state == NULL) {
        put("Could not allocate space for gamestate. Terminating.");
        _terminate(-1);
    }
    state->hugcount = 1000;
    put("Welcome to the hug gambling server.\n");
    put("What is your name?\n");
    bzero(state->name, 256);
    recvUntil(0, state->name, 256, '\n');
    put("Hi ");
    put(state->name);
    put(". ");
    memcpy((char *)&seed, state->name, 4);
    hugsrand(state, seed);
    while(state->hugcount > 0) {
        if(state->hugcount > 1000000)
            state->hugcount = 1000000;
        put("You have ");
        put(itoa(state->hugcount));
        put(" hugs. Shall we play a game?\n1. Coin Flip\n2. Hangman\n3. Dice game\n4. War\nq. Quit\n");
        bzero(choice, 16);
        recvUntil(0, choice, 15, '\n');
        switch(choice[0])
        {
            case '1':
                coinflip();
                break;
            case '2':
                hangman();
                break;
            case '3':
                dicegame();
                break;
            case '4':
                war();
                break;
            case 'q':
                put("Thanks for playing! Don't spend all your hugs in one place.\n");
                _terminate(0);
        }
    }
    put("You're all out of hugs :(. Thanks for playing.\n");

}
예제 #4
0
int main()
{
    int tcase, cnt;
    char correct[1001], guess[1001];
    while(scanf("%d", &tcase) == 1){
        if( tcase == -1)
            break;
        scanf("%s %s", correct, guess);
        cnt = hangman(correct, guess);
        printf("Round %d\n", tcase);
        if(cnt == strlen(correct))
            printf("You win.\n");
        else if(stock == 7)
            printf("You lose.\n");
        else
            printf("You chickened out.\n");
    }
    return 0;
}
예제 #5
0
int main(){

	HANDLE  hConsole;
	hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
	SetConsoleTextAttribute(hConsole, 6);

	int game_count = 0;
	bool repeat = true;
	string answer;
	string difficulty;
	string message = "\nWould you like to play a game of hangman? ";

	cout << "Loading word list...\n";
	// Set seed for random number generation
	srand(time(0));
	// Load up dictionary from "words.txt"
	vector<string> dictionary = loader();

	cout << "The list contains ";

	SetConsoleTextAttribute(hConsole, 2);
	cout << dictionary.size();
	SetConsoleTextAttribute(hConsole, 6);

	cout << " words.\n";
	cout << "\nWelcome. ";

	// Until player selects no
	while (repeat){
		// Check if first round or not
		if (game_count > 0){
			message = "\nWould you like to play another game of hangman? ";
		}

		cout << message;    // COLOR:OFF
		cout << "(";
		SetConsoleTextAttribute(hConsole, 6);
		cout << "y";
		SetConsoleTextAttribute(hConsole, 6);
		cout << "/";
		SetConsoleTextAttribute(hConsole, 6);
		cout << "n";
		SetConsoleTextAttribute(hConsole, 6);
		cout << ") (enter 'scores' to view scoreboard)\n";
		cin >> answer;

		// If player chooses yes, (1) run hangman (2) print score
		// and, if player wins, (3) run scoreboard
		if (answer == "y" || answer == "Y" || answer == "yes" || answer == "Yes"){
			game_count++;
			int score = hangman(dictionary, 6); // RUN
			cout << "Your score was: ";
			if (score == 0){
				SetConsoleTextAttribute(hConsole, 4); // COLOR::RED
				cout << score << endl;
				SetConsoleTextAttribute(hConsole, 6); // COLOR::YELLOW
			}
			else{
				SetConsoleTextAttribute(hConsole, 2); // COLOR::GREEN
				cout << score << endl;
				SetConsoleTextAttribute(hConsole, 6); // COLOR::YELLOW
			}
			// Check whether game was won
			if (score > 0){
				scoreboard(score);
			}
		}
		// If player chooses no, exit game
		else if (answer == "n" || answer == "N" || answer == "no" || answer == "No"){
			repeat = false;
			string goodbye = "Goodbye!";

			for (int i = 0; i < 80; i++){
				SetConsoleTextAttribute(hConsole, i); // COLOR::i
				goodbye = goodbye.insert(0,"         ");
				cout << goodbye << endl;
			}
		}
		// If player enters p, print contents of "words.txt"
		else if (answer == "p"){
			print_vector(dictionary);
		}
		// If player enters scores, print scoreboard
		else if (answer == "scores"){
			print_scoreboard();
			cout << "\n";
		}
		// Else show error
		else{
			cout << "Invalid command.\n";
		}
	}
	
	return 0;
}
예제 #6
0
파일: Main.cpp 프로젝트: victorhck/AmayaOS
int menu()
{
    char tecla;
    int i;
    u16 *vga;
    MemoryMessage mem;

    /* Request VGA memory. */
    mem.action    = CreatePrivate;
    mem.bytes     = PAGESIZE;
    mem.virtualAddress  = ZERO;
    mem.physicalAddress = VGA_PADDR;
    mem.protection      = PAGE_RW | PAGE_PINNED;
    mem.ipc(MEMSRV_PID, SendReceive, sizeof(mem));

    /* Point to the VGA mapping. */
    vga = (u16 *) mem.virtualAddress;

    for (i=0; i < 36; i++) {
      vga[i] = VGA_CHAR(' ', GREEN, GREEN);
    }
    vga[36] = VGA_CHAR('A', BLACK, GREEN);
    vga[37] = VGA_CHAR('m', BLACK, GREEN);
    vga[38] = VGA_CHAR('a', BLACK, GREEN);
    vga[39] = VGA_CHAR('y', BLACK, GREEN);
    vga[40] = VGA_CHAR('a', BLACK, GREEN);
    vga[41] = VGA_CHAR('O', BLACK, GREEN);
    vga[42] = VGA_CHAR('S', BLACK, GREEN);
    for (i=43; i < 80; i++) {
      vga[i] = VGA_CHAR(' ', GREEN, GREEN);
    }
    for (i=80; i < 1680; i++) {
      vga[i] = VGA_CHAR(' ', WHITE, WHITE);
    }
    vga[1520] = VGA_CHAR('A', BLUE, BROWN);
    vga[1521] = VGA_CHAR('m', BLUE, BROWN);
    vga[1522] = VGA_CHAR('a', BLUE, BROWN);
    vga[1523] = VGA_CHAR('C', BLUE, BROWN);
    vga[1524] = VGA_CHAR('A', BLUE, BROWN);
    vga[1525] = VGA_CHAR('L', BLUE, BROWN);
    vga[1526] = VGA_CHAR('C', BLUE, BROWN);
    vga[1527] = VGA_CHAR(' ', BLUE, BROWN);
    vga[1528] = VGA_CHAR('(', BLUE, BROWN);
    vga[1529] = VGA_CHAR('A', BLUE, BROWN);
    vga[1530] = VGA_CHAR(')', BLUE, BROWN);
    vga[1531] = VGA_CHAR(' ', BLUE, BROWN);
    vga[1600] = VGA_CHAR('H', BLUE, BROWN);
    vga[1601] = VGA_CHAR('a', BLUE, BROWN);
    vga[1602] = VGA_CHAR('n', BLUE, BROWN);
    vga[1603] = VGA_CHAR('g', BLUE, BROWN);
    vga[1604] = VGA_CHAR('m', BLUE, BROWN);
    vga[1605] = VGA_CHAR('a', BLUE, BROWN);
    vga[1606] = VGA_CHAR('n', BLUE, BROWN);
    vga[1607] = VGA_CHAR(' ', BLUE, BROWN);
    vga[1608] = VGA_CHAR('(', BLUE, BROWN);
    vga[1609] = VGA_CHAR('H', BLUE, BROWN);
    vga[1610] = VGA_CHAR(')', BLUE, BROWN);
    vga[1611] = VGA_CHAR(' ', BLUE, BROWN);
    vga[1680] = VGA_CHAR('W', BLUE, BROWN);
    vga[1681] = VGA_CHAR('a', BLUE, BROWN);
    vga[1682] = VGA_CHAR('m', BLUE, BROWN);
    vga[1683] = VGA_CHAR('a', BLUE, BROWN);
    vga[1684] = VGA_CHAR('/', BLUE, BROWN);
    vga[1685] = VGA_CHAR('W', BLUE, BROWN);
    vga[1686] = VGA_CHAR('A', BLUE, BROWN);
    vga[1687] = VGA_CHAR('+', BLUE, BROWN);
    vga[1688] = VGA_CHAR('(', BLUE, BROWN);
    vga[1689] = VGA_CHAR('W', BLUE, BROWN);
    vga[1690] = VGA_CHAR(')', BLUE, BROWN);
    vga[1691] = VGA_CHAR(' ', BLUE, BROWN);
    for (i=1692; i < 1760; i++) {
      vga[i] = VGA_CHAR(' ', WHITE, WHITE);
    }
    vga[1760] = VGA_CHAR('R', BLUE, BROWN);
    vga[1761] = VGA_CHAR('e', BLUE, BROWN);
    vga[1762] = VGA_CHAR('i', BLUE, BROWN);
    vga[1763] = VGA_CHAR('n', BLUE, BROWN);
    vga[1764] = VGA_CHAR('i', BLUE, BROWN);
    vga[1765] = VGA_CHAR('c', BLUE, BROWN);
    vga[1766] = VGA_CHAR('i', BLUE, BROWN);
    vga[1767] = VGA_CHAR('a', BLUE, BROWN);
    vga[1768] = VGA_CHAR('r', BLUE, BROWN);
    vga[1769] = VGA_CHAR('(', BLUE, BROWN);
    vga[1770] = VGA_CHAR('R', BLUE, BROWN);
    vga[1771] = VGA_CHAR(')', BLUE, BROWN);
    for (i=1772; i < 1840; i++) {
      vga[i] = VGA_CHAR(' ', WHITE, WHITE);
    }
    vga[1840] = VGA_CHAR('S', BLUE, BROWN);
    vga[1841] = VGA_CHAR('h', BLUE, BROWN);
    vga[1842] = VGA_CHAR('e', BLUE, BROWN);
    vga[1843] = VGA_CHAR('l', BLUE, BROWN);
    vga[1844] = VGA_CHAR('l', BLUE, BROWN);
    vga[1845] = VGA_CHAR('(', BLUE, BROWN);
    vga[1846] = VGA_CHAR('S', BLUE, BROWN);
    vga[1847] = VGA_CHAR(')', BLUE, BROWN);
    vga[1848] = VGA_CHAR(' ', BLUE, BROWN);
    vga[1849] = VGA_CHAR(' ', BLUE, BROWN);
    vga[1850] = VGA_CHAR(' ', BLUE, BROWN);
    vga[1851] = VGA_CHAR(' ', BLUE, BROWN);
    memoria();
    do {
      tecla = getchar();
    } while (tecla != 'R'&& tecla != 'r'&& tecla != 'S'&& tecla != 's'&& 'M'&& tecla != 'm'&& tecla != 'W'&& tecla != 'w'
             &&tecla != 'H'&& tecla != 'h' &&tecla != 'A'&& tecla != 'a');
    if (tecla == 'M'|| tecla == 'm') {
      return 0;
    }
    if (tecla == 'R'|| tecla == 'r') {
      return PrivExec(Reboot);
    }
    if (tecla == 'S'|| tecla == 's') {
      return -1;
    }
    if (tecla == 'W'|| tecla == 'w') {
      wama();
    }
/*
    if (tecla == 'P'|| tecla == 'p') {
      game();
    }
*/
    if (tecla == 'H'|| tecla == 'h') {
      hangman();
    }
    if (tecla == 'A'|| tecla == 'a') {
      ama_calc();
    }

    return 0;
}