Skip to content

Commit

Permalink
统一UTF-8编码
Browse files Browse the repository at this point in the history
  • Loading branch information
404name committed Mar 22, 2021
1 parent 74d8ae2 commit 9923581
Show file tree
Hide file tree
Showing 18 changed files with 3,033 additions and 2,085 deletions.
168 changes: 84 additions & 84 deletions 俄罗斯方块Plus/游戏源码.txt

Large diffs are not rendered by default.

122 changes: 61 additions & 61 deletions 俄罗斯方块Plus/经典版demo(600行待缩减).cpp
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
#include <conio.h> //用于getch()
#include <conio.h> //用于getch()
#include <math.h>
#include <stdio.h>
#include <stdlib.h> //用于rand
#include <stdlib.h> //用于rand
#include <string.h>
#include <time.h>
#include <windows.h>
//■□
//■□
/*-----
日志:
·人物移动格外算时间,有下降加快更新,上升同样,这时候不算随机数,平常走动随机数
·win画面更新。开头介绍,胜利。下降时间控制
日志:
·人物移动格外算时间,有下降加快更新,上升同样,这时候不算随机数,平常走动随机数
·win画面更新。开头介绍,胜利。下降时间控制
Expand All @@ -19,8 +19,8 @@ int map[500][500] = {0};
int color_map[500][500] = {0};
int check_sum[500][2] = {0};
int if_full = 0;
//下标按顺序为 总分 应该下降的层数
//逻辑顺序是谁 check_sun储存对应map层数的和,当满的时候,他向上的有值的层数就要增加相应的该降层数。
//下标按顺序为 总分 应该下降的层数
//逻辑顺序是谁 check_sun储存对应map层数的和,当满的时候,他向上的有值的层数就要增加相应的该降层数。
int height, width, top;
int start_x = 6, start_y = 10, tx, ty, x, y, times, cnt_time, old_index0, index0, cnt = 0;
int if_change = 0, if_death = 0, reduce_time = 0;
Expand All @@ -29,34 +29,34 @@ int next_position_x[2] = {1, 1}, next_position_y[2] = {10, 2}, show_next = 0, sh
int now_color = 3, next_color = 2, next_next_color = 3;

int death_line = 8;
char message[7][20] = { //自定义logo
char message[7][20] = { //自定义logo
{"[][][][][]"},
{"[Tetris ]"},
{"[ plus]"},
{"[俄罗斯 ]"},
{"[方块plus]"},
{"[俄罗斯 ]"},
{"[方块plus]"},
{"[][][][][]"}};
struct Pass
{
char ss[10][11];
} pass[20] = {
{{{"0000000000"}, //1可以自己设置基础关卡 0空气 1砖块
{{{"0000000000"}, //1可以自己设置基础关卡 0空气 1砖块
{"0000000000"},
{"0000000000"},
{"0000000000"},
{"0000000020"},
{"0000000000"},
{"0000000000"},
{"0000000000"}}}};
int now_pass = 1; //多关卡,现在默认第一关
int now_pass = 1; //多关卡,现在默认第一关

int T[30][4] = { //7种4*4状态,对应的数据是4位数对应4种情况(有效数前面不能为零不然会认为其他进制)
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, 0000, 0000, 0000}, //
{0000, 1111, 1111, 0000},
{0000, 1111, 1111, 0000},
{0000, 0000, 0000, 0000},
Expand All @@ -66,22 +66,22 @@ struct Pass
{101, 0000, 0000, 0000},
{101, 0000, 0000, 0000},

{1000, 1010, 1, 0000}, //右L
{1000, 1010, 1, 0000}, //右L
{101, 1111, 101, 0000},
{100, 1010, 10, 0000},
{0000, 0000, 0000, 0000},

{0001, 1010, 10, 0000}, //左L
{0001, 1010, 10, 0000}, //左L
{101, 1111, 101, 0000},
{1000, 1010, 100, 0000},
{0000, 0000, 0000, 0000},

{0000, 1111, 101, 0000}, //右与
{0000, 1111, 101, 0000}, //右与
{101, 1111, 1010, 0000},
{0000, 0000, 1010, 0000},
{0000, 0000, 0000, 0000},

{101, 1111, 0000, 0000}, //左与
{101, 1111, 0000, 0000}, //左与
{1010, 1111, 101, 0000},
{1010, 0000, 0000, 0000},
{0000, 0000, 0000, 0000}};
Expand All @@ -91,13 +91,13 @@ int show(int out, int in, int if_auto, int class0);
void init_brick();
void death_line_drop(int turn);
void check();
void HideCursor() //光标隐藏
void HideCursor() //光标隐藏
{
CONSOLE_CURSOR_INFO cursor_info = {1, 0}; //后边的0代表光标不可见
CONSOLE_CURSOR_INFO cursor_info = {1, 0}; //后边的0代表光标不可见
SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE), &cursor_info);
}

void gotoxy(int x, int y) //坐标函数
void gotoxy(int x, int y) //坐标函数
{
HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE);
COORD pos;
Expand All @@ -120,10 +120,10 @@ void init_brick()
next_turn = next_next_turn;
next_next_turn = rand() % 7;
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), next_color);
show_next = 1; //打印下下个
show_next = 1; //打印下下个
show(1, 1, 1, 1);
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), next_next_color);
show_next = 2; //打印下个
show_next = 2; //打印下个
show(1, 1, 1, 1);
show_next = 0;
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), now_color);
Expand All @@ -134,7 +134,7 @@ void init_brick()

void init(int pass0)
{
HideCursor(); //隐藏光标
HideCursor(); //隐藏光标
int i, j;
system("cls");
times = 500;
Expand All @@ -146,27 +146,27 @@ void init(int pass0)
death_line = 8;
height = 26;
width = 23;
//游戏开始样式
//游戏开始样式
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("");
printf("");
else
printf("");
printf("");
}
}
gotoxy(6, height / 2 - 2);
printf("[Pass: No%2d]", pass0);
gotoxy(6, height / 2);
printf("[Start game]");
getchar();
//点击开始
//点击开始
gotoxy(0, 0);
//构建地图
//构建地图
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 3);
for (i = 0; i <= height; i++)
{
Expand All @@ -191,14 +191,14 @@ void init(int pass0)
{
printf("[]");
}
//这里是从17行开始打印8行关卡。
//这里是从17行开始打印8行关卡。
else if (i >= (height - 8) && pass[pass0 - 1].ss[i - (height - 8)][j / 2 - 1] != '0' && pass0 != 0)
{
if (pass[pass0 - 1].ss[i - (height - 8)][j / 2 - 1] == '1')
{
map[i][j] = 2;
check_sum[i][0] += 2;
printf("");
printf("");
}
else
printf(" ");
Expand Down Expand Up @@ -243,9 +243,9 @@ void init(int pass0)
getch();
}

void death_line_drop(int turn) //0对应打印 1对应下降
void death_line_drop(int turn) //0对应打印 1对应下降
{
//清空死亡线
//清空死亡线
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 3);
gotoxy(0, death_line);
printf("[]");
Expand All @@ -257,9 +257,9 @@ void init(int pass0)
if (map[death_line][i] != 1)
printf(" ");
}
if (turn == 1) //是否下降
if (turn == 1) //是否下降
death_line++;
//打印新的死亡线
//打印新的死亡线
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 4);
gotoxy(0, death_line);
printf("{}");
Expand All @@ -282,7 +282,7 @@ void init(int pass0)

void delete_line()
{
HideCursor(); //隐藏光标
HideCursor(); //隐藏光标
int i, j, temp = 0;
for (i = height - 1; i >= death_line; i--)
{
Expand All @@ -296,7 +296,7 @@ void delete_line()
}
}
}
//下降
//下降
for (i = height - 1; i >= death_line; i--)
{
if (check_sum[i][1])
Expand All @@ -307,7 +307,7 @@ void delete_line()
for (j = 2; j <= width - 2; j = j + 2)
{
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), color_map[i][j]);
map[i][j] == 2 ? printf("") : printf(" ");
map[i][j] == 2 ? printf("") : printf(" ");
map[i + check_sum[i][1]][j] = map[i][j];
}
gotoxy(2, i);
Expand All @@ -321,7 +321,7 @@ void delete_line()
}
check();
Sleep(50);
//刷新死亡线
//刷新死亡线
death_line_drop(0);
}

Expand All @@ -339,7 +339,7 @@ int get_index0_num(int res, int index0)
return ans;
}

int show(int out, int in, int if_auto, int class0) //是否清除 是否加载 是否自动下落 赋值类型(1在移动 2定位的)
int show(int out, int in, int if_auto, int class0) //是否清除 是否加载 是否自动下落 赋值类型(1在移动 2定位的)
{
int i, j;
int temp_x;
Expand All @@ -359,7 +359,7 @@ int get_index0_num(int res, int index0)
now_turn = (show_next == 2 ? next_next_turn : next_turn);
tx = x, ty = y;
}
if (out == 1) //清除
if (out == 1) //清除
{
for (i = tx; i < tx + 4; i++)
{
Expand All @@ -382,9 +382,9 @@ int get_index0_num(int res, int index0)
}
}
}
if (in == 1) //打印
if (in == 1) //打印
{
int now_turn_index = now_turn * 4; //对应到的初始下标
int now_turn_index = now_turn * 4; //对应到的初始下标
for (i = x; i < x + 4; i++)
{
for (j = y; j < y + 4; j++)
Expand All @@ -404,9 +404,9 @@ int get_index0_num(int res, int index0)
color_map[i][2 * j - y] = now_color;
}
if (!(class0 == 2 && i <= death_line))
printf("");
printf("");
}
else if (i <= height && 2 * j - y <= width && get_index0_num(T[i - x + now_turn_index][j - y], index0) == 1 && map[i][2 * j - y] == 2 && if_auto == 1) //失败则回退
else if (i <= height && 2 * j - y <= width && get_index0_num(T[i - x + now_turn_index][j - y], index0) == 1 && map[i][2 * j - y] == 2 && if_auto == 1) //失败则回退
{
if (show_first)
{
Expand All @@ -420,7 +420,7 @@ int get_index0_num(int res, int index0)
show(1, 1, 1, 1);
return 0;
}
else if (i <= height && 2 * j - y <= width && get_index0_num(T[i - x + now_turn_index][j - y], index0) == 1 && map[i][2 * j - y] == 2) //失败则回退
else if (i <= height && 2 * j - y <= width && get_index0_num(T[i - x + now_turn_index][j - y], index0) == 1 && map[i][2 * j - y] == 2) //失败则回退
{
int ttx = tx;
int tty = ty;
Expand Down Expand Up @@ -460,7 +460,7 @@ int get_index0_num(int res, int index0)
return 1;
}

void check() //统计每层的得分情况
void check() //统计每层的得分情况
{
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 3);
for (int i = 6; i < height; i++)
Expand All @@ -472,7 +472,7 @@ int get_index0_num(int res, int index0)
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), now_color);
}

void manchange() //人为输入更新
void manchange() //人为输入更新
{
char ch, ch1, ch2;
if (kbhit())
Expand All @@ -481,7 +481,7 @@ int get_index0_num(int res, int index0)
if (ch != ' ' && ch != 'w' && ch != 's' && ch != 'a' && ch != 'd' && ch != -32 && ch != 'p' && ch != 'b')
return;
if (ch == -32)
{ //同时启用wasd 和上下左右键
{ //同时启用wasd 和上下左右键
ch1 = getch();
switch (ch1)
{
Expand Down Expand Up @@ -527,9 +527,9 @@ int get_index0_num(int res, int index0)
}
}
}
void autochange() //自动更新
void autochange() //自动更新
{
times--; //模拟sleep函数
times--; //模拟sleep函数
if (times == 0)
{
cnt_time++;
Expand All @@ -548,7 +548,7 @@ int get_index0_num(int res, int index0)
if (cnt_time == 20 && now_pass != 0)
{
cnt_time = 0;
//是否开启死亡线下降: 0否 1是
//是否开启死亡线下降: 0否 1是
death_line_drop(0);
}
}
Expand All @@ -559,16 +559,16 @@ int main()
system("mode con cols=50 lines=28");
HideCursor();
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 3);
printf("****** 游戏名: 俄罗斯方块Tetris Plus ******\n");
printf("****** 游戏名: 俄罗斯方块Tetris Plus ******\n");
printf("****** ******\n");
printf("****** 程序作者: 404name ******\n");
printf("****** 程序作者: 404name ******\n");
printf("****** ******\n");
printf("****** 操作方式: ←左移动 ******\n");
printf("****** 操作方式: →右移动 ******\n");
printf("****** 操作方式: ↑上旋转 ******\n");
printf("****** 操作方式: ↓加速下降 ******\n");
printf("****** 操作方式: 回车确认键 ******\n");
printf("****** 建议游戏字号大小为26号 ******\n");
printf("****** 操作方式: ←左移动 ******\n");
printf("****** 操作方式: →右移动 ******\n");
printf("****** 操作方式: ↑上旋转 ******\n");
printf("****** 操作方式: ↓加速下降 ******\n");
printf("****** 操作方式: 回车确认键 ******\n");
printf("****** 建议游戏字号大小为26号 ******\n");
getchar();
gotoxy(0, 0);
system("mode con cols=28 lines=28");
Expand Down
Binary file not shown.
Loading

0 comments on commit 9923581

Please sign in to comment.