#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <termios.h>
#include <pthread.h>
#include <signal.h>
#include <math.h>
enum {
S_VERTICAL,
S_HORIZON,
S_SQUARE,
S_THUNDER_1,
S_THUNDER_2,
S_THUNDER_3,
S_THUNDER_4,
S_EL_1,
S_EL_2,
S_EL_3,
S_EL_4,
S_EL_5,
S_EL_6,
S_EL_7,
S_EL_8,
S_TBRANCH_1,
S_TBRANCH_2,
S_TBRANCH_3,
S_TBRANCH_4,
};
enum {
LEFT,
RIGHT,
DOWN,
UP
};
typedef struct point {
int x;
int y;
}point;
struct shape {
int type;
point point[4];
int sid;
};
struct shape smap[] = {
{0,0,0,1,0,2,0,3,0,0},
{1,0,3,0,2,0,1,0,0,0},
{2,0,0,0,1,1,0,1,1,0},
{3,0,1,1,0,1,1,2,0,0},
{4,2,2,1,1,2,1,1,0,0},
{5,0,0,1,0,1,1,2,1,0},
{6,1,2,1,1,2,1,2,0,0},
{7,1,2,2,0,2,1,2,2,0},
{8,2,1,0,0,1,0,2,0,0},
{9,2,0,1,2,1,1,1,0,0},
{10,0,0,2,1,1,1,0,1,0},
{11,1,0,2,0,2,1,2,2,0},
{12,0,1,0,0,1,0,2,0,0},
{13,2,2,1,2,1,1,1,0,0},
{14,2,0,2,1,1,1,0,1,0},
{15,1,1,2,0,2,1,2,2,0},
{16,1,1,0,0,1,0,2,0,0},
{17,1,1,0,2,0,1,0,0,0},
{18,1,0,2,1,1,1,0,1,0}
};
int bitmap[20][10];
pthread_mutex_t mlock = PTHREAD_MUTEX_INITIALIZER;
struct shape curshape, nextshape;
int g_id = 1;
int score = 0;
int level = 1;
int linestat[20] = {0};
int leftedge = 0, rightedge = 0, bottom = 0;;
long long lasttime = 0;
int state;
int nexts;
struct termios new_setting,init_setting;
void clear_full_line();
int next_shape(int curs)
{
switch (curs) {
case S_HORIZON:
case S_THUNDER_2:
case S_THUNDER_4:
return curs - 1;
case S_EL_4:
case S_EL_8:
case S_TBRANCH_4:
return curs - 3;
case S_SQUARE:
return curs;
default:
return curs + 1;
}
}
void draw_bitmap()
{
int i, j, k;
printf("\033[2J");
int news[4][4] = {0};
for (i = 0; i < 4; i++) {
news[smap[nexts].point[i].x][smap[nexts].point[i].y] =
linux环境纯命令行俄罗斯方块C语言版
最新推荐文章于 2022-02-24 08:51:40 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)