#include <conio.h> //用于getch()
#include <math.h>
#include <stdio.h>
#include <stdlib.h> //用于rand
#include <string.h>
#include <time.h>
#include <windows.h>
//■□
/*-------------------------
程序名: 俄罗斯方块Tetris Plus
日志:
·人物移动格外算时间,有下降加快更新,上升同样,这时候不算随机数,平常走动随机数
·win画面更新。开头介绍,胜利。下降时间控制
-----------------------*/
int map[500][500] = {0};
int color_map[500][500] = {0};
int check_sum[500][2] = {0};
int if_full;
//下标按顺序为 总分 应该下降的层数
//逻辑顺序是谁 check_sun储存对应map层数的和,当满的时候,他向上的有值的层数就要增加相应的该降层数。
int height, width, top;
int start_x, start_y, tx, ty, x, y, times, cnt_time, old_index0, index0;
int if_change, if_death, reduce_time;
int now_turn, next_turn, next_next_turn;
int next_position_x[2] = {1, 1}, next_position_y[2] = {10, 2}, show_next, show_first;
int now_color, next_color, next_next_color;
int man_x, man_y, v, man_up_down;
char man_top_right[3], man_buttom_left[3], man_top_left[3], man_buttom_right[3];
char commom_man[5][3] = { // 0ω0
{"Θ"}, //老头
{"Θ"},
{"老"},
{"头"}};
char going_to_die_man[5][3] = { //
{"凉"}, //
{"凉"},
{"老"},
{"头"}};
int death_line = 8;
char message[7][20] = {
{"[][][][][]"},
{"[Tetris ]"},
{"[ plus]"},
{"[俄罗斯 ]"},
{"[方块plus]"},
{"[][][][][]"}};
struct Pass
{
char ss[10][11];
} pass[20] = {
{{{"0000000000"}, //1
{"0000000000"},
{"0000000000"},
{"0000000000"},
{"1110000020"},
{"1111101111"},
{"0000000000"},
{"0000000000"}}},
{{{"0000000000"}, //2
{"0000000000"},
{"0000000000"},
{"0000000000"},
{"0000000000"},
{"0001201000"},
{"0001111000"},
{"0001111000"}}},
{{{"0000000000"}, //3
{"0000000000"},
{"0000000000"},
{"0000000000"},
{"0000200000"},
{"0111111110"},
{"0111111110"},
{"0111111110"}}},
{{{"0000000000"}, //4
{"0000000000"},
{"0000000000"},
{"0000200000"},
{"0000110000"},
{"0001001000"},
{"0010000100"},
{"0100000010"}}},
{{{"0000000000"}, //5
{"0000000000"},
{"0001001000"},
{"0010000100"},
{"0010200100"},
{"0001111000"},
{"0001001000"},
{"0001001000"}}},
{{{"0000000000"}, //6
{"0000020000"},
{"0000001000"},
{"0000011100"},
{"0000111110"},
{"0001111111"},
{"0011111111"},
{"0111111111"}}},
{{{"0000000000"}, //7
{"0000200000"},
{"0001111100"},
{"0011111110"},
{"0111111111"},
{"0111111110"},
{"0111111110"},
{"0011111100"}}},
{{{"0000000000"}, //8
{"0000200000"},
{"0000110000"},
{"0001111111"},
{"0011011111"},
{"0111111111"},
{"0000000000"},
{"0000000000"}}},
{{{"0000000000"}, //9
{"0000002000"},
{"0000011111"},
{"0101011111"},
{"0000011111"},
{"0000011111"},
{"0000011111"},
{"0000011111"}}},
{{{"0000000000"}, //10
{"0000000000"},
{"0000000020"},
{"1000000001"},
{"0100000010"},
{"0010000100"},
{"0001001000"},
{"0000110000"}}},
{{{"0000010000"}, //11
{"0000011000"},
{"0000011100"},
{"0000010110"},
{"0020010010"},
{"0111110000"},
{"0111100000"},
{"0011000000"}}},
{{{"0000000000"}, //12
{"0000000000"},
{"0100200010"},
{"0011111100"},
{"0000110000"},
{"0000110000"},
{"0000110000"},
{"0001111000"}}},
{{{"0000000000"}, //13
{"0000000000"},
{"0000000000"},
{"0010000100"},
{"0100200010"},
{"0010100100"},
{"0000010000"},
{"0000100000"}}},
{{{"0000000000"}, //14
{"0000020000"},
{"0001111100"},
{"0000000010"},
{"0011111010"},
{"0100000010"},
{"0100000010"},
{"0000000000"}}},
{{{"0000200000"}, //15
{"0011111100"},
{"0111111110"},
{"0111111110"},
{"0111111110"},
{"0111001110"},
{"1011001101"},
{"0101111010"}}},
{{{"0000000000"}, //16
{"0000000000"},
{"0000200000"},
{"0000000000"},
{"1010101010"},
{"0101010101"},
{"1010101010"},
{"0101010101"}}}};
int now_pass;
int T[30][4] = { //7种4*4状态,对应的数据是4位数对应4种情况(有效数前面不能为零不然会认为其他进制)
{0000, 1011, 0000, 0000}, //T
{1101, 1111, 111, 0000},
{0000, 1110, 0000, 0000},
{0000, 0000, 0000, 0000},
{0000, 0000, 0000, 0000}, //田
{0000, 1111, 1111, 0000},
{0000, 1111, 1111, 0000},
{0000, 0000, 0000, 0000},
{1111, 1010, 1010, 1010}, //l
{101, 0000, 0000, 0000},
{101, 0000, 0000, 0000},
{101, 0000, 0000, 0000},
{1000, 1010, 1, 0000}, //右L
{101, 1111, 101, 0000},
{100, 1010, 10, 0000},
{0000, 0000, 0000, 0000},
{0001, 1010, 10, 0000}, //左L
{101, 1111, 101, 0000},
{1000, 1010, 100, 0000},
{0000, 0000, 0000, 0000},
{0000, 1111, 101, 0000}, //右与
{101, 1111, 1010, 0000},
{0000, 0000, 1010, 0000},
{0000, 0000, 0000, 0000},
{101, 1111, 0000, 0000}, //左与
{1010, 1111, 101, 0000},
{1010, 0000, 0000, 0000},
{0000, 0000, 0000, 0000}};
void HideCursor();
int show(int out, int in, int if_auto, int class0);
void init_brick();
void death_line_drop(int turn);
void man_move();
void check();
void HideCursor() //光标隐藏
{
CONSOLE_CURSOR_INFO cursor_info = {1, 0}; //后边的0代表光标不可见
SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE), &cursor_info);
}
void gotoxy(int x, int y) //坐标函数
{
HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE);
COORD pos;
pos.X = x;
pos.Y = y;
SetConsoleCursorPosition(handle, pos);
}
void init_brick()
{
now_color = next_color;
next_color = next_next_color;
next_next_color = rand() % 9;
if (next_next_color == 0)
next_next_color = 1;
x = start_x;
y = start_y;
tx = x, ty = y;
now_turn = next_turn;
next_turn = next_next_turn;
next_next_turn = rand() % 7;
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), next_color);
show_next = 1; //打印下下个
show(1, 1, 1, 1);
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), next_next_color);
show_next = 2; //打印下个
show(1, 1, 1, 1);
show_next = 0;
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), now_color);
show_first = 1;
show(1, 1, 1, 1);
show_first = 0;
}
void init(int pass0)
{
int i, j;
HideCursor(); //隐藏光标
system("cls");
times = 500;
cnt_time = 0;
index0 = 1;
x = start_x, y = start_y;
tx = x, ty = y;
top = 5;
death_line = 8;
height = 26;
width = 23;
if_full = 0, if_change = 0, if_death = 0, reduce_time = 0;
next_turn = rand() % 7;
next_next_turn = rand() % 7;
now_turn = rand() % 7;
v = 2, man_up_down = 0;
start_x = 6, start_y = 10;
show_first = 0;
strcpy(man_top_left, commom_man[0]);
strcpy(man_top_right, commom_man[1]);
strcpy(man_buttom_left, commom_man[2]);
strcpy(man_buttom_right, commom_man[3]);
//游戏开始样式
for (i = 0; i <= height; i++)
{
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), rand() % 8 + 1);
for (j = 0; j <= width; j = j + 2)
{
gotoxy(j, i);
if (i == 0 || i == height || j == 0 || j == width - 1)
printf("■");
else
printf("□");
}