我的创作纪念日

机缘

2022年9月14日,我发现了这个网站并注册了帐号,随后闲的无聊写了一篇文风优(ruo)美(zhi),全是知(fei)识(hua)的文章。当时,我写好描述,发了出去,但后来我再次闲的无聊的时候在必应上搜我的文章,搜是能搜到,但是描述不一样(闲的无聊的可以去验证一下,现在不知道这个bug有没有修复)


收获

收获的话,那当然是三连写作水平和关注我的粉丝们,谢谢你们为我送上你宝贵的关注!

在这里特别感谢@YUTUmini@C++橙羊吖@耐心的阿米巴Yaozy,他们对我的前期有很大的贡献!


日常

现在的日常的话,无非就是刷刷算法题、学一学Unity和OpenGL、写写游戏、打打游戏什么的……

至于创作的话……有时候会发些动态什么的,这个暑假过完你们应该就能看到我的游戏了(如果我不懒的话)


成就

写的最好的代码啊……那肯定是这个了:

#include <bits/stdc++.h>
#include <conio.h>
#include <windows.h>
 
using namespace std;
 
void Clear_Screen() {    
    HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
    COORD coordScreen = {0, 0};
    SetConsoleCursorPosition(hConsole, coordScreen);
}
 
void color(int m) {
	HANDLE consolehend;
	consolehend = GetStdHandle(STD_OUTPUT_HANDLE);
	SetConsoleTextAttribute(consolehend, m);
}
 
string a[9] = {
	"#####################################################################################################", 
	"#                                                                                                   #",
	"#                               *                                 *                                E#",
	"#                             #####                             W####                             W##",
	"#                            #### #                             W## #                             W##",
	"#          #   #   #        ##### #                             W## #                             W##",
	"#         ## # # # # #     ###### #                             W## #                             W##",
	"################################# ########M###MMM###MM############# ########M###MMM###MM#############",
	"#####################################################################################################"
};
 
class monster {
	public:
		bool direc = 0;
		int Mx = 6;
		int My = 5;
		void move() {
			if (a[Mx + 1][My] != '#' && Mx + 1 < 8) {
				Mx++;
			}
			if (direc == 0) {
				if (a[Mx][My + 1] == '#') {
					int t = Mx;
					for (int i = t; i >= t - 3; i--) {
						if (a[i][My] == '#') {
							break;
						}
						Mx--;
					}
				}
				My = My + 1;
			} else {
				if (a[Mx][My - 1] == '#') {
					int t = Mx;
					for (int i = t; i >= t - 3; i--) {
						if (a[i][My] == '#') {
							break;
						}
						Mx--;
					}
				}
				My = My - 1;
			}
			if ((My == 98 && direc == 0) || (My == 1 && direc == 1)) {
				direc = !direc;
			} 
		}
};
 
int Bx = 6;
int By = 1;
int x = 6;
int y = 1;
bool flag = 0;
bool costume = 0;
monster Mons;
 
void check() {
	if (a[x][y] == 'M') {
		x = Bx;
		y = By;
	}
	if (a[x][y] == '*') {
		Bx = x;
		By = y;
	}
	if (a[x][y] == 'W') {
		costume = 1;
	} else {
		costume = 0;
	}
	if (a[x][y] == 'E') {
		flag = 1;
	}
}
 
int main() {
	while (1) {
		Sleep(50);
		Mons.move();
		if (a[x + 1][y] != '#' && a[x + 1][y] != 'W' && x + 1 < 9) {
			x++;
			check();
		}
		if (x == Mons.Mx - 1 || x == Mons.Mx || x == Mons.Mx + 1) {
			if (y == Mons.My - 1 || y == Mons.My || y == Mons.My + 1) {
				x = Bx;
				y = By;
			}
		}
		Clear_Screen();
		printf("   嗨~欢迎来到字符酷跑,在这里,I是你,#是墙,M是岩浆,碰到了就会死了,W是水,可以游上去,*是存档点  \n");
		printf("                          E就是终点,还有,w往上跳,a向左走,d向右走,加油~                          \n");
		for (int i = 0; i < 9; i++) {
			int len = a[i].size();
			for (int j = 0; j < len; j++) {
				if (i == x && j == y) {
					if (costume == 0) {
						color(6);
						printf("I");
					} else {
						color(1);
						printf("U");
					}
					continue;
				} 
				if (i == Mons.Mx && j == Mons.My) {
					color(6);
					printf("?");
					continue;
				}
				switch (a[i][j]) {
					case '*':
						color(2);
						printf("%c", a[i][j]);
						break;
					case 'M':
						color(4);
						printf("%c", a[i][j]);
						break;
					case 'W':
						color(9);
						printf("%c", a[i][j]);
						break;
					case 'E':
						color(14);
						printf("%c", a[i][j]);
						break;
					default:
						color(0xF);
						printf("%c", a[i][j]);
						break;
				}
			}
			printf("\n");
		}
		if (flag) {
			break;
		}
		color(0xF);
		if (GetKeyState('A') < 0 && a[x][y - 1] != '#') {
			y--;
		}
		if (GetKeyState('D') < 0 && a[x][y + 1] != '#') {
			y++; 
			check();
		}
		if (GetKeyState('W') < 0 && (a[x - 1][y] == 'W' || a[x + 1][y] == 'W')) {
			costume = 1;
			x--;
		} else if (GetKeyState('W') < 0 && a[x + 1][y] == '#') {
			costume = 0;
			int t = x;
			for (int i = t; i >= t - 4; i--) {
				if (a[i][y] == '#') {
					break;
				}
				x--;
				check();
			}
		}
		if (GetKeyState('S') < 0 && (a[x - 1][y] == 'W' || a[x + 1][y] == 'W') && a[x + 1][y] != '#') {
			x++;
			costume = 1;
			check();
		}
	}
	system("cls");
	printf("You Win!");
	return 0;
}

这个代码出自C++ 字符跑酷#5 游戏制作实录,没什么人看,但是我个人觉得是挺厉害的(毕竟我可是一个人想出的代码逻辑呢!)

这个游戏也是我写的最久的游戏呢(虽然到现在他还依然只有190行代码)


憧憬

愿望的话,那当然是我写的代码没有bug了(这个愿望神的实现不了)!

未来应该会更加努力地写代码吧,应该在暑假之后就能看到我的游戏了吧……

总之,谢谢你看完了这篇水得不能再水的文章,如果喜欢的话就点个三连加关注吧~!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值