linux控制台下实现2048小游戏

2019-10-14 10:57:09于丽

int put_to(int line, int row);
#endif

2048.c


#include"2048.h"
int start_game()
{
    system("clear");
    printf("33[?25l");
    print_start();
    ran_appear();
    print_num();
    print_score();
    print_getchar();
    printf("33[?25h");
}
int print_getchar()
{
    struct termios old,new;
    int ch;
    tcgetattr(0,&old);
    tcgetattr(0,&new);
    new.c_lflag = new.c_lflag &~(ICANON |ECHO);
    new.c_cc[VTIME]=0;
    new.c_cc[VMIN]=1;
    tcsetattr(0,TCSANOW,&new);
    while(1)
    {
        if(end_flag==1)
            break;
        ch=getchar();
        if(ch=='33')
        {
            ch=getchar();
            if(ch=='[')
            {
                ch=getchar();
                switch(ch)
                {
                    case 'A':
                        mov_up();
                        is_full();
                        break;
                    case 'B':
                        mov_down();
                        is_full();
                        break;
                    case 'C':