Example #1
0
void
taku_wo_miseru(Taku *taku)
{
    cursur_position(0, 0);
    erase_display(ENTIRE);
    print_taku(taku);
    key_break();
}
Example #2
0
File: main.c Project: outsky/tetris
static void quit(void)
{
    restore();
    restore_input(&org);
    erase_display();
    pthread_mutex_destroy(&mut);
    pthread_cond_destroy(&cond);
    printf("\n");
    exit(0);
}
Example #3
0
File: main.c Project: outsky/tetris
int main()
{
    struct sigaction sa;
    memset(&sa, 0, sizeof(struct sigaction));
    sa.sa_handler = sigint;
    sigaction(SIGINT, &sa, NULL);
    atexit(quit);
    prepare_input(&org);
    erase_display();

    srand(time(NULL));
    game_init();
    draw();

    pthread_mutex_init(&mut, NULL);
    pthread_cond_init(&cond, NULL);

    pthread_t tid;
    pthread_create(&tid, NULL, trd_timer, NULL);
    pthread_detach(tid);
    pthread_create(&tid, NULL, trd_draw, NULL);
    pthread_detach(tid);

    int c;
    while(EOF != (c=getchar())) {
        if(c == 'j') {
            move_down();
        } else if(c == 'k') {
            rotate();
        } else if(c == 'h') {
            move_left();
        } else if(c == 'l') {
            move_right();
        } else if(c == 32) {
            drop_down();
        } else if(c == 'q') {
            quit();
        } else {
            continue;
        }
    }

    return 0;
}