项目地址

Linux实验作业描述

1.0 beta

#define BOOMMAXNUM 100
#define MAPMAXSIZE 21
#define BOOMTIME 3 //炸弹爆炸时间
#define BOOMLIVETIME 1 //炸弹效果时间
#define FPSOFTHISGAME 24 //帧数

#include <string>//取随机数
#include <stdio.h>//输出
#include <Windows.h>//取按键信息
#include <time.h>//取时间

int map[MAPMAXSIZE * MAPMAXSIZE];//0空地,1可摧毁的墙,2不可摧毁的墙
int boom[BOOMMAXNUM * 3];//0炸弹坐标,1炸弹放置时间,2炸弹有效范围
int booml, boomr;
int person1[2];
int person2[2];
bool isMapChanged;//这是cls后重新绘制防止闪烁使用的,如果有可以在指定位置输出字符的函数可以不需要
bool isFinished;

bool isBoom(int boomLocation) {
    int point = booml;
    for (int i = 0; i < (boomr + BOOMMAXNUM - booml) % BOOMMAXNUM; i++) {
        if (boom[point * 3 + 0] == boomLocation) return true;
        point = (point + 1) % BOOMMAXNUM;
    }
    return false;
}

void begin() {
    srand(time(0));
    for (int i = 0; i < MAPMAXSIZE; i++) {
        map[0 * MAPMAXSIZE + i] = 2;
        map[i * MAPMAXSIZE + 0] = 2;
        map[(MAPMAXSIZE - 1) * MAPMAXSIZE + i] = 2;
        map[i * MAPMAXSIZE + (MAPMAXSIZE - 1)] = 2;
    }
    for (int i = 1; i < (MAPMAXSIZE - 1); i++) {
        for (int j = 1; j < (MAPMAXSIZE - 1); j++) {
            if (i % 2 == 0 && j % 2 == 0) map[i * MAPMAXSIZE + j] = rand() % 3;
            else map[i * MAPMAXSIZE + j] = rand() % 2;
        }
    }
    map[1 * MAPMAXSIZE + 1] = map[2 * MAPMAXSIZE + 1] = map[1 * MAPMAXSIZE + 2] = map[(MAPMAXSIZE - 2) * MAPMAXSIZE + (MAPMAXSIZE - 2)] = map[(MAPMAXSIZE - 2) * MAPMAXSIZE + (MAPMAXSIZE - 3)] = map[(MAPMAXSIZE - 3) * MAPMAXSIZE + (MAPMAXSIZE - 2)] = 0;
    person1[0] = person1[1] = 1;
    person2[0] = person2[1] = MAPMAXSIZE - 2;
    isMapChanged = true;//这是cls后重新绘制防止闪烁使用的,如果有可以在指定位置输出字符的函数可以不需要
}

void draw() {
    for (int i = 0; i < MAPMAXSIZE*MAPMAXSIZE; i++) {
        if (map[i] > 2 && time(0) - map[i] >= BOOMLIVETIME)
            isMapChanged = true;//这是cls后重新绘制防止闪烁使用的,如果有可以在指定位置输出字符的函数可以不需要
    }
    if (!isMapChanged)return;//这是cls后重新绘制防止闪烁使用的,如果有可以在指定位置输出字符的函数可以不需要
    isMapChanged = false;//这是cls后重新绘制防止闪烁使用的,如果有可以在指定位置输出字符的函数可以不需要
    system("cls");
    for (int i = 0; i < MAPMAXSIZE; i++) {
        for (int j = 0; j < MAPMAXSIZE; j++) {
            if (person1[0] == i && person1[1] == j)printf("\033[1;33;40m@\033[0m");
            else if (person2[0] == i && person2[1] == j)printf("\033[1;34;40m@\033[0m");
            else if (isBoom(i * MAPMAXSIZE + j))printf("\033[1;31;40mB\033[0m");
            else if (map[i * MAPMAXSIZE + j] == 0) printf(" ");
            else if (map[i * MAPMAXSIZE + j] == 1)printf("\033[1;32;40m#\033[0m");
            else if (map[i * MAPMAXSIZE + j] == 2)printf("#");
            else if (map[i * MAPMAXSIZE + j] > 2) {
                printf("=");
                if (time(0) - map[i * MAPMAXSIZE + j] >= BOOMLIVETIME) {
                    map[i * MAPMAXSIZE + j] = 0;
                    isMapChanged = true;//这是cls后重新绘制防止闪烁使用的,如果有可以在指定位置输出字符的函数可以不需要
                }
            }
        }
        printf("\n");
    }
}

void booooom() {
    while (booml != boomr && (time(0) - boom[booml * 3 + 1] >= BOOMTIME)) {
        for (int i = 0; i <= boom[booml * 3 + 2]; i++) {
            if (map[boom[booml * 3] + i] == 1) { map[boom[booml * 3] + i] = time(0); break; }
            else if (map[boom[booml * 3] + i] == 2)break;
            else map[boom[booml * 3] + i] = time(0);
        }
        for (int i = 0; i <= boom[booml * 3 + 2]; i++) {
            if (map[boom[booml * 3] - i] == 1) { map[boom[booml * 3] - i] = time(0); break; }
            else if (map[boom[booml * 3] - i] == 2)break;
            else map[boom[booml * 3] - i] = time(0);
        }
        for (int i = 0; i <= boom[booml * 3 + 2]; i++) {
            if (map[boom[booml * 3] + i * MAPMAXSIZE] == 1) { map[boom[booml * 3] + i * MAPMAXSIZE] = time(0); break; }
            else if (map[boom[booml * 3] + i * MAPMAXSIZE] == 2)break;
            else map[boom[booml * 3] + i * MAPMAXSIZE] = time(0);
        }
        for (int i = 0; i <= boom[booml * 3 + 2]; i++) {
            if (map[boom[booml * 3] - i * MAPMAXSIZE] == 1) { map[boom[booml * 3] - i * MAPMAXSIZE] = time(0); break; }
            else if (map[boom[booml * 3] - i * MAPMAXSIZE] == 2)break;
            else map[boom[booml * 3] - i * MAPMAXSIZE] = time(0);
        }
        boom[booml + 2] = 0;
        boom[booml + 1] = 0;
        boom[booml + 0] = 0;
        booml=(booml+1)%BOOMMAXNUM;
        isMapChanged = true;//这是cls后重新绘制防止闪烁使用的,如果有可以在指定位置输出字符的函数可以不需要
        if (map[person1[0] * MAPMAXSIZE + person1[1]] > 2 && map[person2[0] * MAPMAXSIZE + person2[1]] > 2) {
            printf("DRAW!");
            isFinished = true;
            break;
        }
        else if (map[person1[0] * MAPMAXSIZE + person1[1]] > 2) {
            printf("Player 2 WIN!");
            isFinished = true;
            break;
        }
        else if (map[person2[0] * MAPMAXSIZE + person2[1]] > 2) {
            printf("Player 1 WIN!");
            isFinished = true;
            break;
        };
    }
}

void control() {//注意,两个人的移动及炸弹放置是独立的,所以只有两人各自的操作使用了else if
    if (GetKeyState('W')<0) {
        if (map[(person1[0] - 1) * MAPMAXSIZE + person1[1]] == 0 && !isBoom((person1[0] - 1) * MAPMAXSIZE + person1[1])) {
            person1[0]--;
            isMapChanged = true;//这是cls后重新绘制防止闪烁使用的,如果有可以在指定位置输出字符的函数可以不需要
        }
    }
    else if (GetKeyState('A')<0) {
        if (map[(person1[0]) * MAPMAXSIZE + person1[1] - 1] == 0 && !isBoom((person1[0]) * MAPMAXSIZE + person1[1] - 1)) {
            person1[1]--;
            isMapChanged = true;//这是cls后重新绘制防止闪烁使用的,如果有可以在指定位置输出字符的函数可以不需要
        }
    }
    else if (GetKeyState('D')<0) {
        if (map[(person1[0]) * MAPMAXSIZE + person1[1] + 1] == 0 && !isBoom((person1[0]) * MAPMAXSIZE + person1[1] + 1)) {
            person1[1]++;
            isMapChanged = true;//这是cls后重新绘制防止闪烁使用的,如果有可以在指定位置输出字符的函数可以不需要
        }
    }
    else if (GetKeyState('S')<0) {
        if (map[(person1[0] + 1) * MAPMAXSIZE + person1[1]] == 0 && !isBoom((person1[0] + 1) * MAPMAXSIZE + person1[1])) {
            person1[0]++;
            isMapChanged = true;//这是cls后重新绘制防止闪烁使用的,如果有可以在指定位置输出字符的函数可以不需要
        }
    }

    if (GetKeyState(VK_UP)<0) {
        if (map[(person2[0] - 1) * MAPMAXSIZE + person2[1]] == 0 && !isBoom((person2[0] - 1) * MAPMAXSIZE + person2[1])) {
            person2[0]--;
            isMapChanged = true;//这是cls后重新绘制防止闪烁使用的,如果有可以在指定位置输出字符的函数可以不需要
        }
    }
    else if (GetKeyState(VK_LEFT)<0) {
        if (map[(person2[0]) * MAPMAXSIZE + person2[1] - 1] == 0 && !isBoom((person2[0]) * MAPMAXSIZE + person2[1] - 1)) {
            person2[1]--;
            isMapChanged = true;//这是cls后重新绘制防止闪烁使用的,如果有可以在指定位置输出字符的函数可以不需要
        }
    }
    else if (GetKeyState(VK_RIGHT)<0) {
        if (map[(person2[0]) * MAPMAXSIZE + person2[1] + 1] == 0 && !isBoom((person2[0]) * MAPMAXSIZE + person2[1] + 1)) {
            person2[1]++;
            isMapChanged = true;//这是cls后重新绘制防止闪烁使用的,如果有可以在指定位置输出字符的函数可以不需要
        }
    }
    else if (GetKeyState(VK_DOWN)<0) {
        if (map[(person2[0] + 1) * MAPMAXSIZE + person2[1]] == 0 && !isBoom((person2[0] + 1) * MAPMAXSIZE + person2[1])) {
            person2[0]++;
            isMapChanged = true;//这是cls后重新绘制防止闪烁使用的,如果有可以在指定位置输出字符的函数可以不需要
        }
    }

    if (GetKeyState(VK_SPACE)<0) {
        if (!isBoom(person1[0] * MAPMAXSIZE + person1[1])) {
            boom[boomr * 3 + 0] = person1[0] * MAPMAXSIZE + person1[1];
            boom[boomr * 3 + 1] = time(0);
            boom[boomr * 3 + 2] = 1;
            boomr = (boomr + 1) % BOOMMAXNUM;
            isMapChanged = true;//这是cls后重新绘制防止闪烁使用的,如果有可以在指定位置输出字符的函数可以不需要
        }
    }

    if (GetKeyState(VK_RETURN)<0) {
        if (!isBoom(person2[0] * MAPMAXSIZE + person2[1])) {
            boom[boomr * 3 + 0] = person2[0] * MAPMAXSIZE + person2[1];
            boom[boomr * 3 + 1] = time(0);
            boom[boomr * 3 + 2] = 1;
            boomr = (boomr + 1) % BOOMMAXNUM;
            isMapChanged = true;//这是cls后重新绘制防止闪烁使用的,如果有可以在指定位置输出字符的函数可以不需要
        }
    }
}

void main() {
    begin();
    while (!isFinished) {
        Sleep(1000 / FPSOFTHISGAME);
        draw();
        control();
        booooom();
    }
    Sleep(5000);
}

2.0 beta

#!/bin/bash
cat>temp___.c<<EOF
#define BOOMMAXNUM 100
#define MAPMAXSIZE 40    
#define BOOMTIME 3 //炸弹爆炸时间    
#define BOOMLIVETIME 1 //炸弹效果时间   
#define FPSOFTHISGAME 24 //帧数    
#define bool int
#define true 1
#define false 0
#define VK_SPACE          32
#define VK_LEFT           8
#define VK_UP             5
#define VK_RIGHT          7
#define VK_DOWN           6
#define VK_RETURN         10


//#include <string.h>//取随机数
#include <stdio.h>//输出
#include <stdlib.h>
//#include <Windows.h>//取按键信息
#include <time.h>//取时间
#include <termio.h>  
  
///////
///////
int map[MAPMAXSIZE * MAPMAXSIZE];//0空地,1可摧毁的墙,2不可摧毁的墙
int boom[BOOMMAXNUM * 3];//0炸弹坐标,1炸弹放置时间,2炸弹有效范围
int booml, boomr;
int person1[2];
int person2[2];
bool isMapChanged;//这是cls后重新绘制防止闪烁使用的,如果有可以在指定位置输出字符的函数可以不需要
bool isFinished;

bool isBoom(int boomLocation) {
    int point = booml;
    for (int i = 0; i < (boomr + BOOMMAXNUM - booml) % BOOMMAXNUM; i++) {
        if (boom[point * 3 + 0] == boomLocation) return true;
        point = (point + 1) % BOOMMAXNUM;
    }
    return false;
}

void begin() {
    srand( (unsigned)time( NULL ) );
    for (int i = 0; i < MAPMAXSIZE; i++) {
        map[0 * MAPMAXSIZE + i] = 2;
        map[i * MAPMAXSIZE + 0] = 2;
        map[(MAPMAXSIZE - 1) * MAPMAXSIZE + i] = 2;
        map[i * MAPMAXSIZE + (MAPMAXSIZE - 1)] = 2;
    }
    for (int i = 1; i < (MAPMAXSIZE - 1); i++) {
        for (int j = 1; j < (MAPMAXSIZE - 1); j++) {
            if (i % 2 == 0 && j % 2 == 0) map[i * MAPMAXSIZE + j] = rand() % 3;
            else map[i * MAPMAXSIZE + j] = rand() % 2;
        }
    }
    map[1 * MAPMAXSIZE + 1] = map[2 * MAPMAXSIZE + 1] = map[1 * MAPMAXSIZE + 2] = map[(MAPMAXSIZE - 2) * MAPMAXSIZE + (MAPMAXSIZE - 2)] = map[(MAPMAXSIZE - 2) * MAPMAXSIZE + (MAPMAXSIZE - 3)] = map[(MAPMAXSIZE - 3) * MAPMAXSIZE + (MAPMAXSIZE - 2)] = 0;
    person1[0] = person1[1] = 1;
    person2[0] = person2[1] = MAPMAXSIZE - 2;
    isMapChanged = true;//这是cls后重新绘制防止闪烁使用的,如果有可以在指定位置输出字符的函数可以不需要
}

void draw() {
    for (int i = 0; i < MAPMAXSIZE*MAPMAXSIZE; i++) {
        if (map[i] > 2 && time(0) - map[i] >= BOOMLIVETIME)
            isMapChanged = true;//这是cls后重新绘制防止闪烁使用的,如果有可以在指定位置输出字符的函数可以不需要
    }
    if (!isMapChanged)return;//这是cls后重新绘制防止闪烁使用的,如果有可以在指定位置输出字符的函数可以不需要
    isMapChanged = false;//这是cls后重新绘制防止闪烁使用的,如果有可以在指定位置输出字符的函数可以不需要
    printf("\n");
    system("clear");
    for (int i = 0; i < MAPMAXSIZE; i++) {
        for (int j = 0; j < MAPMAXSIZE; j++) {
            if (person1[0] == i && person1[1] == j)printf("\033[1;33;40m@\033[0m");
            else if (person2[0] == i && person2[1] == j)printf("\033[1;34;40m@\033[0m");
            else if (isBoom(i * MAPMAXSIZE + j))printf("\033[1;31;40mB\033[0m");
            else if (map[i * MAPMAXSIZE + j] == 0) printf(" ");
            else if (map[i * MAPMAXSIZE + j] == 1)printf("\033[1;32;40m#\033[0m");
            else if (map[i * MAPMAXSIZE + j] == 2)printf("#");
            else if (map[i * MAPMAXSIZE + j] > 2) {
                printf("=");
                if (time(0) - map[i * MAPMAXSIZE + j] >= BOOMLIVETIME) {
                    map[i * MAPMAXSIZE + j] = 0;
                    isMapChanged = true;//这是cls后重新绘制防止闪烁使用的,如果有可以在指定位置输出字符的函数可以不需要
                }
            }
        }
        printf("\n");
    }
}

void booooom() {
    while (booml != boomr && (time(0) - boom[booml * 3 + 1] >= BOOMTIME)) {
        for (int i = 0; i <= boom[booml * 3 + 2]; i++) {
            if (map[boom[booml * 3] + i] == 1) { map[boom[booml * 3] + i] = time(0); break; }
            else if (map[boom[booml * 3] + i] == 2)break;
            else map[boom[booml * 3] + i] = time(0);
        }
        for (int i = 0; i <= boom[booml * 3 + 2]; i++) {
            if (map[boom[booml * 3] - i] == 1) { map[boom[booml * 3] - i] = time(0); break; }
            else if (map[boom[booml * 3] - i] == 2)break;
            else map[boom[booml * 3] - i] = time(0);
        }
        for (int i = 0; i <= boom[booml * 3 + 2]; i++) {
            if (map[boom[booml * 3] + i * MAPMAXSIZE] == 1) { map[boom[booml * 3] + i * MAPMAXSIZE] = time(0); break; }
            else if (map[boom[booml * 3] + i * MAPMAXSIZE] == 2)break;
            else map[boom[booml * 3] + i * MAPMAXSIZE] = time(0);
        }
        for (int i = 0; i <= boom[booml * 3 + 2]; i++) {
            if (map[boom[booml * 3] - i * MAPMAXSIZE] == 1) { map[boom[booml * 3] - i * MAPMAXSIZE] = time(0); break; }
            else if (map[boom[booml * 3] - i * MAPMAXSIZE] == 2)break;
            else map[boom[booml * 3] - i * MAPMAXSIZE] = time(0);
        }
        boom[booml + 2] = 0;
        boom[booml + 1] = 0;
        boom[booml + 0] = 0;
        booml=(booml+1)%BOOMMAXNUM;
        isMapChanged = true;//这是cls后重新绘制防止闪烁使用的,如果有可以在指定位置输出字符的函数可以不需要
        if (map[person1[0] * MAPMAXSIZE + person1[1]] > 2 && map[person2[0] * MAPMAXSIZE + person2[1]] > 2) {
            printf("DRAW!");
            isFinished = true;
            break;
        }
        else if (map[person1[0] * MAPMAXSIZE + person1[1]] > 2) {
            system("clear");
            printf("\nPlayer 2 WIN!\n");
            isFinished = true;
            break;
        }
        else if (map[person2[0] * MAPMAXSIZE + person2[1]] > 2) {
            system("clear");
            printf("\nPlayer 1 WIN!\n");
            isFinished = true;
            break;
        };
    }
}
  
char scanKeyboard()  
{  
    int in;  
    struct termios new_settings;  
    struct termios stored_settings;  
    tcgetattr(0,&stored_settings);  
    new_settings = stored_settings;  
    new_settings.c_lflag &= (~ICANON);  
    new_settings.c_cc[VTIME] = 0;  
    tcgetattr(0,&stored_settings);  
    new_settings.c_cc[VMIN] = 1;  
    tcsetattr(0,TCSANOW,&new_settings);  

    in = getchar();  

    tcsetattr(0,TCSANOW,&stored_settings);  
    return in;      
}

char GetKeyState(){
    char ch;
    ch = scanKeyboard();
    if (ch==27){
        ch = scanKeyboard();
        ch = scanKeyboard();
        return ch-60;
    }
    return ch;
}

void control() {//注意,两个人的移动及炸弹放置是独立的,所以只有两人各自的操作使用了else if
    char ch=GetKeyState();
        if (ch=='w'||ch=='W') {
            if (map[(person1[0] - 1) * MAPMAXSIZE + person1[1]] == 0 && !isBoom((person1[0] - 1) * MAPMAXSIZE + person1[1])) {
                person1[0]--;
                isMapChanged = true;//这是cls后重新绘制防止闪烁使用的,如果有可以在指定位置输出字符的函数可以不需要
            }
        }
        else if (ch=='a'||ch=='A') {
            if (map[(person1[0]) * MAPMAXSIZE + person1[1] - 1] == 0 && !isBoom((person1[0]) * MAPMAXSIZE + person1[1] - 1)) {
                person1[1]--;
                isMapChanged = true;//这是cls后重新绘制防止闪烁使用的,如果有可以在指定位置输出字符的函数可以不需要
            }
        }
        else if (ch=='d'||ch=='D') {
            if (map[(person1[0]) * MAPMAXSIZE + person1[1] + 1] == 0 && !isBoom((person1[0]) * MAPMAXSIZE + person1[1] + 1)) {
                person1[1]++;
                isMapChanged = true;//这是cls后重新绘制防止闪烁使用的,如果有可以在指定位置输出字符的函数可以不需要
            }
        }
        else if (ch=='s'||ch=='S') {
            if (map[(person1[0] + 1) * MAPMAXSIZE + person1[1]] == 0 && !isBoom((person1[0] + 1) * MAPMAXSIZE + person1[1])) {
                person1[0]++;
                isMapChanged = true;//这是cls后重新绘制防止闪烁使用的,如果有可以在指定位置输出字符的函数可以不需要
            }
        }

        if (ch==VK_UP) {
            if (map[(person2[0] - 1) * MAPMAXSIZE + person2[1]] == 0 && !isBoom((person2[0] - 1) * MAPMAXSIZE + person2[1])) {
                person2[0]--;
                isMapChanged = true;//这是cls后重新绘制防止闪烁使用的,如果有可以在指定位置输出字符的函数可以不需要
            }
        }
        else if (ch==VK_LEFT) {
            if (map[(person2[0]) * MAPMAXSIZE + person2[1] - 1] == 0 && !isBoom((person2[0]) * MAPMAXSIZE + person2[1] - 1)) {
                person2[1]--;
                isMapChanged = true;//这是cls后重新绘制防止闪烁使用的,如果有可以在指定位置输出字符的函数可以不需要
            }
        }
        else if (ch==VK_RIGHT) {
            if (map[(person2[0]) * MAPMAXSIZE + person2[1] + 1] == 0 && !isBoom((person2[0]) * MAPMAXSIZE + person2[1] + 1)) {
                person2[1]++;
                isMapChanged = true;//这是cls后重新绘制防止闪烁使用的,如果有可以在指定位置输出字符的函数可以不需要
            }
        }
        else if (ch==VK_DOWN) {
            if (map[(person2[0] + 1) * MAPMAXSIZE + person2[1]] == 0 && !isBoom((person2[0] + 1) * MAPMAXSIZE + person2[1])) {
                person2[0]++;
                isMapChanged = true;//这是cls后重新绘制防止闪烁使用的,如果有可以在指定位置输出字符的函数可以不需要
            }
        }

        if (ch==VK_SPACE) {
            if (!isBoom(person1[0] * MAPMAXSIZE + person1[1])) {
                boom[boomr * 3 + 0] = person1[0] * MAPMAXSIZE + person1[1];
                boom[boomr * 3 + 1] = time(0);
                boom[boomr * 3 + 2] = 3;
                boomr = (boomr + 1) % BOOMMAXNUM;
                isMapChanged = true;//这是cls后重新绘制防止闪烁使用的,如果有可以在指定位置输出字符的函数可以不需要
            }
        }

        if (ch==VK_RETURN) {
            if (!isBoom(person2[0] * MAPMAXSIZE + person2[1])) {
                boom[boomr * 3 + 0] = person2[0] * MAPMAXSIZE + person2[1];
                boom[boomr * 3 + 1] = time(0);
                boom[boomr * 3 + 2] = 3;
                boomr = (boomr + 1) % BOOMMAXNUM;
                isMapChanged = true;//这是cls后重新绘制防止闪烁使用的,如果有可以在指定位置输出字符的函数可以不需要
            }
        }
        
        
        if (ch==127) {
            system("clear");
            isFinished = true;
        }
    
}

void main() {
    begin();
    while (!isFinished) {
        //sleep(1000 / FPSOFTHISGAME);
        draw();
        control();
        booooom();
    }
    //sleep(5000);
}
EOF
gcc ./temp___.c -o temp___
chmod 777 ./temp___
rm ./temp___.c -rf
./temp___
rm ./temp___ -rf

3.0 正式版?

#!/bin/bash
clear
echo -e "\033[5;33m     .......                                                .&##%                   ...     .        "
echo "   .%##########!                                            :###;                  !###;   .|&&:     "
echo "   :@##!   .&##@:                                           |##&.                 .%##&.   !##@:     "
echo "   |##&.   .&##&.    .&######&.    :@#%:|####@: :@####%.   .&##|!#####!           :@##! .&#######@:  "
echo "  .&##&;:!&###!    :@##@|.;&###!   |#####&&######&%&###!   !#####&|&###!          |##@: .|&###&%%:   "
echo "  ;###########!   ;###!    .&##%. .&###;   |###|   :@##;  .&###;   .&##|         .&##%.   |##&.      " 
echo " .%##&.    |###! .&##%.    .&##|  ;##@:   .&##|    |##&.  :###;    :@##!         !###;   .&##|       "
echo " :@##!     !###! :@##!     |##@: .%##%.   ;##@:   .&##|   |##&.   .%##&.        .%##&.   !##@:       "
echo " |##@;...!@###|  .&##&:  :&##@:  :@##;   .%##%.   ;##@:  .&###%. ;@##@.         :@##!   .%##@: .     "
echo -e ".&#########@!     .&#######@;    |##&.   :@##;   .%##%.  !##&&######|           |##@:    ;#####%.    \033[0m"
echo
echo
echo "Please input a number(10-99) to set mapsize."
read map
echo "Please input a number(1-10) to set boomsize."
read boomsize
echo
cat>temp___.c<<EOF
#define BOOMMAXNUM 100
#define MAPMAXSIZE qwert    
#define BOOMTIME 3 //炸弹爆炸时间    
#define BOOMLIVETIME 1 //炸弹效果时间   
#define FPSOFTHISGAME 24 //帧数    
#define bool int
#define true 1
#define false 0
#define VK_SPACE          32
#define VK_LEFT           8
#define VK_UP             5
#define VK_RIGHT          7
#define VK_DOWN           6
#define VK_RETURN         10


//#include <string.h>//取随机数
#include <stdio.h>//输出
#include <stdlib.h>
//#include <Windows.h>//取按键信息
#include <time.h>//取时间
#include <termio.h>  
  
///////
///////
int map[MAPMAXSIZE * MAPMAXSIZE];//0空地,1可摧毁的墙,2不可摧毁的墙
int boom[BOOMMAXNUM * 3];//0炸弹坐标,1炸弹放置时间,2炸弹有效范围
int booml, boomr;
int person1[2];
int person2[2];
bool isMapChanged;//这是cls后重新绘制防止闪烁使用的,如果有可以在指定位置输出字符的函数可以不需要
bool isFinished;

bool isBoom(int boomLocation) {
    int point = booml;
    for (int i = 0; i < (boomr + BOOMMAXNUM - booml) % BOOMMAXNUM; i++) {
        if (boom[point * 3 + 0] == boomLocation) return true;
        point = (point + 1) % BOOMMAXNUM;
    }
    return false;
}

void begin() {
    srand( (unsigned)time( NULL ) );
    for (int i = 0; i < MAPMAXSIZE; i++) {
        map[0 * MAPMAXSIZE + i] = 2;
        map[i * MAPMAXSIZE + 0] = 2;
        map[(MAPMAXSIZE - 1) * MAPMAXSIZE + i] = 2;
        map[i * MAPMAXSIZE + (MAPMAXSIZE - 1)] = 2;
    }
    for (int i = 1; i < (MAPMAXSIZE - 1); i++) {
        for (int j = 1; j < (MAPMAXSIZE - 1); j++) {
            if (i % 2 == 0 && j % 2 == 0) map[i * MAPMAXSIZE + j] = rand() % 3;
            else map[i * MAPMAXSIZE + j] = rand() % 2;
        }
    }
    map[1 * MAPMAXSIZE + 1] = map[2 * MAPMAXSIZE + 1] = map[1 * MAPMAXSIZE + 2] = map[(MAPMAXSIZE - 2) * MAPMAXSIZE + (MAPMAXSIZE - 2)] = map[(MAPMAXSIZE - 2) * MAPMAXSIZE + (MAPMAXSIZE - 3)] = map[(MAPMAXSIZE - 3) * MAPMAXSIZE + (MAPMAXSIZE - 2)] = 0;
    person1[0] = person1[1] = 1;
    person2[0] = person2[1] = MAPMAXSIZE - 2;
    isMapChanged = true;//这是cls后重新绘制防止闪烁使用的,如果有可以在指定位置输出字符的函数可以不需要
}

void draw() {
    for (int i = 0; i < MAPMAXSIZE*MAPMAXSIZE; i++) {
        if (map[i] > 2 && time(0) - map[i] >= BOOMLIVETIME)
            isMapChanged = true;//这是cls后重新绘制防止闪烁使用的,如果有可以在指定位置输出字符的函数可以不需要
    }
    if (!isMapChanged)return;//这是cls后重新绘制防止闪烁使用的,如果有可以在指定位置输出字符的函数可以不需要
    isMapChanged = false;//这是cls后重新绘制防止闪烁使用的,如果有可以在指定位置输出字符的函数可以不需要
    printf("\n");
    system("clear");
    for (int i = 0; i < MAPMAXSIZE; i++) {
        for (int j = 0; j < MAPMAXSIZE; j++) {
            if (person1[0] == i && person1[1] == j)printf("\033[1;33;40m@\033[0m");
            else if (person2[0] == i && person2[1] == j)printf("\033[1;34;40m@\033[0m");
            else if (isBoom(i * MAPMAXSIZE + j))printf("\033[1;31;40m☢\033[0m");
            else if (map[i * MAPMAXSIZE + j] == 0) printf(" ");
            else if (map[i * MAPMAXSIZE + j] == 1)printf("\033[1;36;40m█\033[0m");
            else if (map[i * MAPMAXSIZE + j] == 2)printf("█");
            else if (map[i * MAPMAXSIZE + j] > 2) {
                printf("※");
                if (time(0) - map[i * MAPMAXSIZE + j] >= BOOMLIVETIME) {
                    map[i * MAPMAXSIZE + j] = 0;
                    isMapChanged = true;//这是cls后重新绘制防止闪烁使用的,如果有可以在指定位置输出字符的函数可以不需要
                }
            }
        }
        printf("\n");
    }
}

void booooom() {
    while (booml != boomr && (time(0) - boom[booml * 3 + 1] >= BOOMTIME)) {
        for (int i = 0; i <= boom[booml * 3 + 2]; i++) {
            if (map[boom[booml * 3] + i] == 1) { map[boom[booml * 3] + i] = time(0); break; }
            else if (map[boom[booml * 3] + i] == 2)break;
            else map[boom[booml * 3] + i] = time(0);
        }
        for (int i = 0; i <= boom[booml * 3 + 2]; i++) {
            if (map[boom[booml * 3] - i] == 1) { map[boom[booml * 3] - i] = time(0); break; }
            else if (map[boom[booml * 3] - i] == 2)break;
            else map[boom[booml * 3] - i] = time(0);
        }
        for (int i = 0; i <= boom[booml * 3 + 2]; i++) {
            if (map[boom[booml * 3] + i * MAPMAXSIZE] == 1) { map[boom[booml * 3] + i * MAPMAXSIZE] = time(0); break; }
            else if (map[boom[booml * 3] + i * MAPMAXSIZE] == 2)break;
            else map[boom[booml * 3] + i * MAPMAXSIZE] = time(0);
        }
        for (int i = 0; i <= boom[booml * 3 + 2]; i++) {
            if (map[boom[booml * 3] - i * MAPMAXSIZE] == 1) { map[boom[booml * 3] - i * MAPMAXSIZE] = time(0); break; }
            else if (map[boom[booml * 3] - i * MAPMAXSIZE] == 2)break;
            else map[boom[booml * 3] - i * MAPMAXSIZE] = time(0);
        }
        boom[booml + 2] = 0;
        boom[booml + 1] = 0;
        boom[booml + 0] = 0;
        booml=(booml+1)%BOOMMAXNUM;
        isMapChanged = true;//这是cls后重新绘制防止闪烁使用的,如果有可以在指定位置输出字符的函数可以不需要
        if (map[person1[0] * MAPMAXSIZE + person1[1]] > 2 && map[person2[0] * MAPMAXSIZE + person2[1]] > 2) {
            printf("▄█▀█ ●DRAW!● █▀█▄");
            isFinished = true;
            break;
        }
        else if (map[person1[0] * MAPMAXSIZE + person1[1]] > 2) {
            system("clear");
            printf("\n▄█▀█ ●Player 2 WIN!\n");
            isFinished = true;
            break;
        }
        else if (map[person2[0] * MAPMAXSIZE + person2[1]] > 2) {
            system("clear");
            printf("\nPlayer 1 WIN!● █▀█▄\n");
            isFinished = true;
            break;
        };
    }
}
  
char scanKeyboard()  
{  
    int in;  
    struct termios new_settings;  
    struct termios stored_settings;  
    tcgetattr(0,&stored_settings);  
    new_settings = stored_settings;  
    new_settings.c_lflag &= (~ICANON);  
    new_settings.c_cc[VTIME] = 0;  
    tcgetattr(0,&stored_settings);  
    new_settings.c_cc[VMIN] = 1;  
    tcsetattr(0,TCSANOW,&new_settings);  

    in = getchar();  

    tcsetattr(0,TCSANOW,&stored_settings);  
    return in;      
}

char GetKeyState(){
    char ch;
    ch = scanKeyboard();
    if (ch==27){
        ch = scanKeyboard();
        ch = scanKeyboard();
        return ch-60;
    }
    return ch;
}

void control() {//注意,两个人的移动及炸弹放置是独立的,所以只有两人各自的操作使用了else if
    char ch=GetKeyState();
        if (ch=='w'||ch=='W') {
            if (map[(person1[0] - 1) * MAPMAXSIZE + person1[1]] == 0 && !isBoom((person1[0] - 1) * MAPMAXSIZE + person1[1])) {
                person1[0]--;
                isMapChanged = true;//这是cls后重新绘制防止闪烁使用的,如果有可以在指定位置输出字符的函数可以不需要
            }
        }
        else if (ch=='a'||ch=='A') {
            if (map[(person1[0]) * MAPMAXSIZE + person1[1] - 1] == 0 && !isBoom((person1[0]) * MAPMAXSIZE + person1[1] - 1)) {
                person1[1]--;
                isMapChanged = true;//这是cls后重新绘制防止闪烁使用的,如果有可以在指定位置输出字符的函数可以不需要
            }
        }
        else if (ch=='d'||ch=='D') {
            if (map[(person1[0]) * MAPMAXSIZE + person1[1] + 1] == 0 && !isBoom((person1[0]) * MAPMAXSIZE + person1[1] + 1)) {
                person1[1]++;
                isMapChanged = true;//这是cls后重新绘制防止闪烁使用的,如果有可以在指定位置输出字符的函数可以不需要
            }
        }
        else if (ch=='s'||ch=='S') {
            if (map[(person1[0] + 1) * MAPMAXSIZE + person1[1]] == 0 && !isBoom((person1[0] + 1) * MAPMAXSIZE + person1[1])) {
                person1[0]++;
                isMapChanged = true;//这是cls后重新绘制防止闪烁使用的,如果有可以在指定位置输出字符的函数可以不需要
            }
        }

        if (ch==VK_UP) {
            if (map[(person2[0] - 1) * MAPMAXSIZE + person2[1]] == 0 && !isBoom((person2[0] - 1) * MAPMAXSIZE + person2[1])) {
                person2[0]--;
                isMapChanged = true;//这是cls后重新绘制防止闪烁使用的,如果有可以在指定位置输出字符的函数可以不需要
            }
        }
        else if (ch==VK_LEFT) {
            if (map[(person2[0]) * MAPMAXSIZE + person2[1] - 1] == 0 && !isBoom((person2[0]) * MAPMAXSIZE + person2[1] - 1)) {
                person2[1]--;
                isMapChanged = true;//这是cls后重新绘制防止闪烁使用的,如果有可以在指定位置输出字符的函数可以不需要
            }
        }
        else if (ch==VK_RIGHT) {
            if (map[(person2[0]) * MAPMAXSIZE + person2[1] + 1] == 0 && !isBoom((person2[0]) * MAPMAXSIZE + person2[1] + 1)) {
                person2[1]++;
                isMapChanged = true;//这是cls后重新绘制防止闪烁使用的,如果有可以在指定位置输出字符的函数可以不需要
            }
        }
        else if (ch==VK_DOWN) {
            if (map[(person2[0] + 1) * MAPMAXSIZE + person2[1]] == 0 && !isBoom((person2[0] + 1) * MAPMAXSIZE + person2[1])) {
                person2[0]++;
                isMapChanged = true;//这是cls后重新绘制防止闪烁使用的,如果有可以在指定位置输出字符的函数可以不需要
            }
        }

        if (ch==VK_SPACE) {
            if (!isBoom(person1[0] * MAPMAXSIZE + person1[1])) {
                boom[boomr * 3 + 0] = person1[0] * MAPMAXSIZE + person1[1];
                boom[boomr * 3 + 1] = time(0);
                boom[boomr * 3 + 2] = boomsize;
                boomr = (boomr + 1) % BOOMMAXNUM;
                isMapChanged = true;//这是cls后重新绘制防止闪烁使用的,如果有可以在指定位置输出字符的函数可以不需要
            }
    system("echo -e '\007'");
        }

        if (ch==VK_RETURN) {
            if (!isBoom(person2[0] * MAPMAXSIZE + person2[1])) {
                boom[boomr * 3 + 0] = person2[0] * MAPMAXSIZE + person2[1];
                boom[boomr * 3 + 1] = time(0);
                boom[boomr * 3 + 2] = boomsize;
                boomr = (boomr + 1) % BOOMMAXNUM;
                isMapChanged = true;//这是cls后重新绘制防止闪烁使用的,如果有可以在指定位置输出字符的函数可以不需要
            }
    system("echo -e '\007'");
        }
        
        
        if (ch==127) {
            system("clear");
            isFinished = true;
        }
    
}

void main() {
    begin();
    while (!isFinished) {
        //sleep(1000 / FPSOFTHISGAME);
        draw();
        control();
        booooom();
    }
    //sleep(5000);
}
EOF
sed -i "s/qwert/$map/g" temp___.c
sed -i "s/boomsize/$boomsize/g" temp___.c
sed -i "s/boomsize/$boomsize/g" temp___.c
gcc ./temp___.c -o temp___
chmod 777 ./temp___
rm ./temp___.c -rf
./temp___
rm ./temp___ -rf

3.1 正式版

#!/bin/bash
clear
echo -e "\033[5;33m     .......                                                .&##%                   ...     .        "
echo "   .%##########!                                            :###;                  !###;   .|&&:     "
echo "   :@##!   .&##@:                                           |##&.                 .%##&.   !##@:     "
echo "   |##&.   .&##&.    .&######&.    :@#%:|####@: :@####%.   .&##|!#####!           :@##! .&#######@:  "
echo "  .&##&;:!&###!    :@##@|.;&###!   |#####&&######&%&###!   !#####&|&###!          |##@: .|&###&%%:   "
echo "  ;###########!   ;###!    .&##%. .&###;   |###|   :@##;  .&###;   .&##|         .&##%.   |##&.      " 
echo " .%##&.    |###! .&##%.    .&##|  ;##@:   .&##|    |##&.  :###;    :@##!         !###;   .&##|       "
echo " :@##!     !###! :@##!     |##@: .%##%.   ;##@:   .&##|   |##&.   .%##&.        .%##&.   !##@:       "
echo " |##@;...!@###|  .&##&:  :&##@:  :@##;   .%##%.   ;##@:  .&###%. ;@##@.         :@##!   .%##@: .     "
echo -e ".&#########@!     .&#######@;    |##&.   :@##;   .%##%.  !##&&######|           |##@:    ;#####%.    \033[0m"
echo
echo
echo "Please input a number(10-99) to set mapsize."
read map
echo "Please input a number(1-10) to set boomsize."
read boomsize
echo 
cat>temp___.c<<EOF
#define BOOMMAXNUM 100
#define MAPMAXSIZE qwert    
#define BOOMTIME 3 //炸弹爆炸时间    
#define BOOMLIVETIME 1 //炸弹效果时间   
#define FPSOFTHISGAME 24 //帧数    
#define bool int
#define true 1
#define false 0
#define VK_SPACE          32
#define VK_LEFT           8
#define VK_UP             5
#define VK_RIGHT          7
#define VK_DOWN           6
#define VK_RETURN         10
#define ECHOFLAGS (ECHO | ECHOE | ECHOK | ECHONL)  

#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <termio.h>  
  

int map[MAPMAXSIZE * MAPMAXSIZE];//0空地,1可摧毁的墙,2不可摧毁的墙
int boom[BOOMMAXNUM * 3];//0炸弹坐标,1炸弹放置时间,2炸弹有效范围
int booml, boomr;
int person1[2];
int person2[2];
bool isMapChanged;
bool isFinished;

bool isBoom(int boomLocation) {
    int point = booml;
    for (int i = 0; i < (boomr + BOOMMAXNUM - booml) % BOOMMAXNUM; i++) {
        if (boom[point * 3 + 0] == boomLocation) return true;
        point = (point + 1) % BOOMMAXNUM;
    }
    return false;
}

void begin() {
    srand( (unsigned)time( NULL ) );
    for (int i = 0; i < MAPMAXSIZE; i++) {
        map[0 * MAPMAXSIZE + i] = 2;
        map[i * MAPMAXSIZE + 0] = 2;
        map[(MAPMAXSIZE - 1) * MAPMAXSIZE + i] = 2;
        map[i * MAPMAXSIZE + (MAPMAXSIZE - 1)] = 2;
    }
    for (int i = 1; i < (MAPMAXSIZE - 1); i++) {
        for (int j = 1; j < (MAPMAXSIZE - 1); j++) {
            if (i % 2 == 0 && j % 2 == 0) map[i * MAPMAXSIZE + j] = rand() % 3;
            else map[i * MAPMAXSIZE + j] = rand() % 2;
        }
    }
    map[1 * MAPMAXSIZE + 1] = map[2 * MAPMAXSIZE + 1] = map[1 * MAPMAXSIZE + 2] = map[(MAPMAXSIZE - 2) * MAPMAXSIZE + (MAPMAXSIZE - 2)] = map[(MAPMAXSIZE - 2) * MAPMAXSIZE + (MAPMAXSIZE - 3)] = map[(MAPMAXSIZE - 3) * MAPMAXSIZE + (MAPMAXSIZE - 2)] = 0;
    person1[0] = person1[1] = 1;
    person2[0] = person2[1] = MAPMAXSIZE - 2;
    isMapChanged = true;
}

void draw() {
    for (int i = 0; i < MAPMAXSIZE*MAPMAXSIZE; i++) {
        if (map[i] > 2 && time(0) - map[i] >= BOOMLIVETIME)
            isMapChanged = true;
    }
    if (!isMapChanged)return;
    isMapChanged = false;
    printf("\n");
    system("clear");
    for (int i = 0; i < MAPMAXSIZE; i++) {
        for (int j = 0; j < MAPMAXSIZE; j++) {
            if (person1[0] == i && person1[1] == j)printf("\033[1;33;40m@\033[0m");
            else if (person2[0] == i && person2[1] == j)printf("\033[1;34;40m@\033[0m");
            else if (isBoom(i * MAPMAXSIZE + j))printf("\033[1;31;40m☢\033[0m");
            else if (map[i * MAPMAXSIZE + j] == 0) printf(" ");
            else if (map[i * MAPMAXSIZE + j] == 1)printf("\033[1;36;40m█\033[0m");
            else if (map[i * MAPMAXSIZE + j] == 2)printf("█");
            else if (map[i * MAPMAXSIZE + j] > 2) {
                printf("※");
                if (time(0) - map[i * MAPMAXSIZE + j] >= BOOMLIVETIME) {
                    map[i * MAPMAXSIZE + j] = 0;
                    isMapChanged = true;
                }
            }
        }
        printf("\n");
    }
}

void booooom() {
    while (booml != boomr && (time(0) - boom[booml * 3 + 1] >= BOOMTIME)) {
        for (int i = 0; i <= boom[booml * 3 + 2]; i++) {
            if (map[boom[booml * 3] + i] == 1) { map[boom[booml * 3] + i] = time(0); break; }
            else if (map[boom[booml * 3] + i] == 2)break;
            else map[boom[booml * 3] + i] = time(0);
        }
        for (int i = 0; i <= boom[booml * 3 + 2]; i++) {
            if (map[boom[booml * 3] - i] == 1) { map[boom[booml * 3] - i] = time(0); break; }
            else if (map[boom[booml * 3] - i] == 2)break;
            else map[boom[booml * 3] - i] = time(0);
        }
        for (int i = 0; i <= boom[booml * 3 + 2]; i++) {
            if (map[boom[booml * 3] + i * MAPMAXSIZE] == 1) { map[boom[booml * 3] + i * MAPMAXSIZE] = time(0); break; }
            else if (map[boom[booml * 3] + i * MAPMAXSIZE] == 2)break;
            else map[boom[booml * 3] + i * MAPMAXSIZE] = time(0);
        }
        for (int i = 0; i <= boom[booml * 3 + 2]; i++) {
            if (map[boom[booml * 3] - i * MAPMAXSIZE] == 1) { map[boom[booml * 3] - i * MAPMAXSIZE] = time(0); break; }
            else if (map[boom[booml * 3] - i * MAPMAXSIZE] == 2)break;
            else map[boom[booml * 3] - i * MAPMAXSIZE] = time(0);
        }
        boom[booml + 2] = 0;
        boom[booml + 1] = 0;
        boom[booml + 0] = 0;
        booml=(booml+1)%BOOMMAXNUM;
        isMapChanged = true;
        if (map[person1[0] * MAPMAXSIZE + person1[1]] > 2 && map[person2[0] * MAPMAXSIZE + person2[1]] > 2) {
            system("clear");
            isFinished = 3;
            break;
        }
        else if (map[person1[0] * MAPMAXSIZE + person1[1]] > 2) {
            system("clear");
            isFinished = 2;
            break;
        }
        else if (map[person2[0] * MAPMAXSIZE + person2[1]] > 2) {
            system("clear");
            isFinished = 1;
            break;
        };
    }
}

char GetKeyState(){
    char ch;
    ch = getchar();
    if (ch==27){
        ch = getchar();
        ch = getchar();
        return ch-60;
    }
    return ch;
}

void control() {
    char ch=GetKeyState();
        if (ch=='w'||ch=='W') {
            if (map[(person1[0] - 1) * MAPMAXSIZE + person1[1]] == 0 && !isBoom((person1[0] - 1) * MAPMAXSIZE + person1[1])) {
                person1[0]--;
                isMapChanged = true;
            }
        }
        else if (ch=='a'||ch=='A') {
            if (map[(person1[0]) * MAPMAXSIZE + person1[1] - 1] == 0 && !isBoom((person1[0]) * MAPMAXSIZE + person1[1] - 1)) {
                person1[1]--;
                isMapChanged = true;
            }
        }
        else if (ch=='d'||ch=='D') {
            if (map[(person1[0]) * MAPMAXSIZE + person1[1] + 1] == 0 && !isBoom((person1[0]) * MAPMAXSIZE + person1[1] + 1)) {
                person1[1]++;
                isMapChanged = true;
            }
        }
        else if (ch=='s'||ch=='S') {
            if (map[(person1[0] + 1) * MAPMAXSIZE + person1[1]] == 0 && !isBoom((person1[0] + 1) * MAPMAXSIZE + person1[1])) {
                person1[0]++;
                isMapChanged = true;
            }
        }

        if (ch==VK_UP) {
            if (map[(person2[0] - 1) * MAPMAXSIZE + person2[1]] == 0 && !isBoom((person2[0] - 1) * MAPMAXSIZE + person2[1])) {
                person2[0]--;
                isMapChanged = true;
            }
        }
        else if (ch==VK_LEFT) {
            if (map[(person2[0]) * MAPMAXSIZE + person2[1] - 1] == 0 && !isBoom((person2[0]) * MAPMAXSIZE + person2[1] - 1)) {
                person2[1]--;
                isMapChanged = true;
            }
        }
        else if (ch==VK_RIGHT) {
            if (map[(person2[0]) * MAPMAXSIZE + person2[1] + 1] == 0 && !isBoom((person2[0]) * MAPMAXSIZE + person2[1] + 1)) {
                person2[1]++;
                isMapChanged = true;
            }
        }
        else if (ch==VK_DOWN) {
            if (map[(person2[0] + 1) * MAPMAXSIZE + person2[1]] == 0 && !isBoom((person2[0] + 1) * MAPMAXSIZE + person2[1])) {
                person2[0]++;
                isMapChanged = true;
            }
        }

        if (ch==VK_SPACE) {
            if (!isBoom(person1[0] * MAPMAXSIZE + person1[1])) {
                boom[boomr * 3 + 0] = person1[0] * MAPMAXSIZE + person1[1];
                boom[boomr * 3 + 1] = time(0);
                boom[boomr * 3 + 2] = boomsize;
                boomr = (boomr + 1) % BOOMMAXNUM;
                isMapChanged = true;
            }
           system("echo -e '\007'");
        }

        if (ch==VK_RETURN) {
            if (!isBoom(person2[0] * MAPMAXSIZE + person2[1])) {
                boom[boomr * 3 + 0] = person2[0] * MAPMAXSIZE + person2[1];
                boom[boomr * 3 + 1] = time(0);
                boom[boomr * 3 + 2] = boomsize;
                boomr = (boomr + 1) % BOOMMAXNUM;
                isMapChanged = true;
            }
           system("echo -e '\007'");
        }
        
        
        if (ch==127) {
            system("clear");
            isFinished = 3;
        }
    
}

int main() {
    struct termios temp;              //临时启用的新输入模式
    struct termios original;          //保存原有的输入模式
    tcgetattr(0,&original);           //读取原有的输入模式
    temp = original;                  //复制输入模式
    temp.c_lflag &= (~ICANON);        //使输入立即被读取
    temp.c_lflag &= ~ECHOFLAGS;       //关闭回显
    tcsetattr(0,TCSANOW,&temp);       //载入新的输入模式
    begin();
    while (!isFinished) {
        draw();
        control();
        booooom();
    }
    tcsetattr(0,TCSANOW,&original);   //还原旧的输入模式
    return isFinished;
}
EOF

sed -i "s/qwert/$map/g" temp___.c
sed -i "s/boomsize/$boomsize/g" temp___.c
sed -i "s/boomsize/$boomsize/g" temp___.c
gcc ./temp___.c -o temp___
chmod 777 ./temp___
rm ./temp___.c -rf

./temp___
pd=$? 
case $pd in
    1) echo -e "Player \033[1;33;40m@\033[0m WIN!"
    ;;
    2) echo -e "Player \033[1;34;40m@\033[0m WIN!"
    ;;
    3) echo -e "DRAW!"
    ;;
esac

rm ./temp___ -rf

标签: none

添加新评论