Ejemplo n.º 1
0
// Main---------------------------------------------
int main() {
	ppm_t newPPM = loadPpm("images\\border.ppm");

	char smallPath[60];
	char largePath[60];

	char suit[2];
	char number[2];

	printf("Enter in a suit :");
	scanf("%s" , &suit);

	printf("Enter in a number :");
	scanf("%s" , &number);

	strcpy(smallPath , "images\\small-");
	strcpy(largePath , "images\\large-");

	chooseNumber(number , suit);

	strcat(smallPath , suit);
	strcat(smallPath , ext);

	strcat(largePath , suit);
	strcat(largePath , ext);

	placeNumber(loadPpm(numberPath) , newPPM);
	placeSmallIcon(loadPpm(numberPath) , loadPpm(smallPath) , newPPM);

	cardChooser(loadPpm(smallPath) , newPPM , number);

	savePpm("card.ppm" , newPPM);

	system("pause");
}
Ejemplo n.º 2
0
/**
 * Sudoku entry point.
 *
 * @param argv The command input string.
 */
void sudoku(char* argv) {

    termios oldStatus;

    time_t initialTime = time(NULL);
    time_t elapsedTime;
    srand(initialTime);
    const char* board = boards[rand() % NUM_BOARDS];
    int in, i, j;

    GameState state;

    ioctl(0, TCGETS, (void*) &oldStatus);
    ioctl(0, TCSETS, (void*) &gameStatus);

    intro();

    state.placed = 0;
    for (i = 0; i < 9; i++) {
        for (j = 0; j < 9; j++) {

            state.original[i][j] = state.board[i][j] = board[i+j*9];
            state.solvedBoard[i][j] = board[81+(i+j*9)];

            if (state.board[i][j] != '0') {
                state.placed++;
            }
        }
    }

    elapsedTime = time(NULL) - initialTime;

    state.x = 0;
    state.y = 0;
    state.errors = 0;

    // Reset the screen
    moveCursor(1, 1);
    clearScreen(CLEAR_ALL);

    drawBoard(&state);

    while ((in = getchar()) != 'q') {

        if (in == ESCAPE_CODE && getchar() == CSI) {

            in = getchar();
            if ('A' <= in && in <= 'D') {
                moveInDir(&state, in - 'A');
            }
        } else if (isdigit(in)) {

            placeNumber(&state, in);
            if (state.placed == 81 && state.errors == 0) {

                setForegroundColor(COLOR_GREEN);
                moveCursor(boardTop + 10 * 2 - 1, boardLeft);
                printf("Congratulations! You have solved it correctly.");

                moveCursor(boardTop + 10 * 2 , boardLeft);
                printf("Your time was %d minutes and %d seconds.",elapsedTime / 60, elapsedTime % 60);

                moveCursor(boardTop + 10 * 2 + 1, boardLeft);
                printf("Press enter to exit.");
                setForegroundColor(COLOR_WHITE);

                while (getchar() != '\n');
                break;
            }
        }
    }

    clearScreen(CLEAR_ALL);
    moveCursor(0, 0);
    ioctl(0, TCSETS, (void*) &oldStatus);
}