void base_tetrix_scene::user_fall() { while ( m_pblock->isBlockDown() == 0 ) { m_pblock->fall_slow(); DrawBlock(); } CheckGameStatus(); }
void base_tetrix_scene::user_down() { m_pblock->fall_slow(); DrawBlock(); if ( m_pblock->isBlockDown() != 0 ) { CheckGameStatus(); } }
int sw() { int mode = ONE_PLAYER; char option; clear_window(); printf("=== MODO ===\n"); printf("1. Un Jugador\n"); printf("2. Dos Jugadores\n"); do { option = getchar(); } while(option != '1' && option != '2'); switch (option) { case '2': mode = MULTI_PLAYER; break; default: mode = ONE_PLAYER; } clear_window(); int result = EXIT_SUCCESS; put_ship_on_map(mode); int x = 0; int y = 0; int state = PLAYING; while (state == PLAYING) { print_map(); printf("Pulse 'e' para cerrar Sea War.\nX: "); x = getnum(); printf("%d\nY: ", x); y = getnum(); printf("%d\n", y); if (x < 0 || y < 0) { state = EXIT_SW; } if (game_map[0][y][x] == UNKOWN_WATER || game_map[0][y][x] == UNKOWN_SHIP) { game_map[0][y][x]++; game_map[0][y][x]++; } if (mode == ONE_PLAYER) { x = getRandomNumber(10); y = getRandomNumber(x+1); if (game_map[1][x][y] != WATER && game_map[1][x][y] != SHIP) { game_map[1][x][y]++; } else { for (x = 0, y = 0; game_map[1][y][x] == WATER || game_map[1][y][x] == SHIP; x++) { if (x == 9) { x = 0; y++; } } game_map[1][y][x]++; } } else if (mode == MULTI_PLAYER) { printf("Player 2\nX: "); x = getnum(); printf("%d\nY: ", x); y = getnum(); printf("%d\n", y); if (x < 0 || y < 0) { state = EXIT_SW; } if (game_map[1][y][x] == UNKOWN_WATER || game_map[1][y][x] == UNKOWN_SHIP) { game_map[1][y][x]++; game_map[1][y][x]++; } } if (state != EXIT_SW) { state = CheckGameStatus(); } } print_map(); switch (state) { case WIN: printf("La flota enemiga ha sido destruida.\n"); break; case LOSE: printf("La flota aliada ha sido destruida.\n"); break; case EXIT_SW: printf("Cerrando Sea War.\n"); break; case EQUAL: printf("Las dos flotas han sido destruidas. [EMPATE]\n"); break; default: printf("Sea War Error.\n"); result = EXIT_FAILURE; break; } return result; }