c++沙盒小游戏1.06(6代)

更新了开始动画,修复了一些BUG。

下面是代码:

#include<bits/stdc++.h>//dev专属  VC不用
#include <windows.h>
#include <iostream>
#include <stdio.h>
#include <Windows.h>
#include <conio.h>
#include <string.h>
#include <ctime>
#include <stdlib.h>
#include <vector>
#include <unistd.h>
#include <tchar.h>
#include <fstream>
#include <sys/time.h>
#include<iostream>
#include<bits/stdc++.h>
#include<iomanip>
#include<string>
#include<cstdlib>
#include<ctime>
#include<windows.h>
#include<conio.h>
#include<fstream>
#include <mmsystem.h>
#define qdo 262
#define qre 294
#define qmi 330     //q前缀为低音,1后缀为高音,s前缀为半音阶
#define qfa 349
#define qso 392
#define qla 440
#define qsi 494
#define do 523
#define re 578
#define mi 659
#define fa 698
#define so 784
#define la 880
#define si 988
#define do1 1046
#define re1 1175
#define mi1 1318
#define fa1 1480
#define so1 1568
#define la1 1760
#define si1 1976
#define sqdo 277
#define sqre 311
#define sqfa 370
#define sqso 415
#define sqla 466
#define sdo 554
#define sre 622
#define sfa 740
#define sso 831
#define sla 932
#define sdo1 1046
#define sre1 1245
#define sfa1 1480
#define sso1 1661
#define sla1 1865
#define KEY_DOWN(VK_NONAME) ((GetAsyncKeyState(VK_NONAME) & 0x8000) ? 1:0)
using namespace std;
void cout_sleep(char n[]){
	for(int i=0;i<strlen(n);i++){
		cout<<n[i];
		if(n[i]!=' '){
			Sleep(100);
		}
	}
} 
void gs(long long x, long long y, string str)
{
	for (long long i = 1; i <= x; i++)
		cout << "\n";
	for (long long i = 1; i <= y; i++)
		cout << " ";
	cout << str;
	return;
}

	//结构体与类提前声明
	struct hl//行列
	{
		long long h, l;
	};

	//函数提前声明
	bool axj(long long key);
	hl sbwz(bool x, bool n);//鼠标位置
	void ydgb(long long h, long long l);//移动光标到指定位置
	void yanse(int n);//颜色

	//常量
	const long long ESC = 27,//电脑左上角的esc
		Enter = 13,//回车
		Tab = 9,//esc下面一些的tab
		Shang = 38,//\、
		Xia = 40,//   |方向键
		Zuo = 37,//   |
		You = 39,//  /
		Kong = ' ',//空格
		z_sb = VK_LBUTTON,//鼠标左键
		y_sb = VK_RBUTTON,//鼠标右键
		Shift = VK_SHIFT,//上档
		z_Shift = VK_LSHIFT,//左边的SHIFT
		y_Shift = VK_RSHIFT,//右边的shift
		Ctrl = VK_CONTROL,//控制
		z_Ctrl = VK_LCONTROL,//左边的Ctrl
		y_Ctrl = VK_RCONTROL,//右边的Ctrl
		Alt = VK_MENU,//windows右边的alt
		z_Alt = VK_LMENU,//左……
		y_Alt = VK_RMENU,//右……(我不说也知道)
		A = 'A',//这些就是字母
		B = 'B',
		C = 'C',
		D = 'D',
		E = 'E',
		F = 'F',
		G = 'G',
		H = 'H',
		I = 'I',
		J = 'J', 
		K = 'K',
		L = 'L',
		M = 'M',
		N = 'N',
		O = 'O',
		P = 'P',
		Q = 'Q',
		R = 'R',
		S = 'S',
		T = 'T',
		U = 'U',
		V = 'V',
		W = 'W',
		X = 'X',
		Y = 'Y',
		Z = 'Z';

	//结构体与类
	class anniu//这个是设置按钮的
	{
	private:
		short h_1, l_1, h_2, l_2, ys1, ys2;
		string nr;
	public:
		void csh(short hh_1, short ll_1, short hh_2, short ll_2, string _nr, short _yanse1, short _yanse2);
		bool gx_ax(bool f);
	};
	struct cdhs//存档结构体
	{
		void out(int n, string name);
		void out(long long n, string name);
		void out(bool n, string name);
		void out(char n, string name);
		void out(string n, string name);
		void in(int& n, string name);
		void in(long long& n, string name);
		void in(bool& n, string name);
		void in(char& n, string name);
		void in(string& n, string name);
	};

	//成员函数
	void anniu::csh(short hh_1 = 1, short ll_1 = 1, short hh_2 = 1, short ll_2 = 1, string _nr = " ", short _yanse1 = 240, short _yanse2 = 7)
	{
		h_1 = hh_1;
		l_1 = ll_1;
		h_2 = hh_2;
		l_2 = ll_2;
		ys1 = _yanse1;
		ys2 = _yanse2;
		nr = _nr;
		return;
	}
	bool anniu::gx_ax(bool f = 1)
	{
		short h = sbwz(1, 1).h, l = sbwz(1, 1).l, t = -1;
		if (h >= h_1 && h <= h_2 && l >= l_1 && l <= l_2)
		{
			yanse(ys2);
			for (short i = h_1; i <= h_2; i++)
			{
				ydgb(i, l_1);
				for (short j = l_1; j <= l_2; j++)
				{
					t++;
					cout << nr[t];
				}
			}
			if ((axj(z_sb) && (f == 1)) || (axj(y_sb) && (f == 0)))
			{
				return 1;
			}
		}
		else
		{
			yanse(ys1);
			for (short i = h_1; i <= h_2; i++)
			{
				ydgb(i, l_1);
				for (short j = l_1; j <= l_2; j++)
				{
					t++;
					cout << nr[t];
				}
			}
			return 0;
		}
	}
	void cdhs::out(int n, string name)//存档,以后更新时会用的,保存数值
	{
		ofstream cd(&name[0]);
		cd << n;
		cd.close();
		return;
	}
	void cdhs::out(long long n, string name)
	{
		ofstream cd(&name[0]);
		cd << n;
		cd.close();
		return;
	}
	void cdhs::out(bool n, string name)
	{
		ofstream cd(&name[0]);
		cd << n;
		cd.close();
		return;
	}
	void cdhs::out(char n, string name)
	{
		ofstream cd(&name[0]);
		cd << n;
		cd.close();
		return;
	}
	void cdhs::out(string n, string name)
	{
		ofstream cd(&name[0]);
		cd << n;
		cd.close();
		return;
	}
	void cdhs::in(int& n, string name)
	{
		ifstream cd(&name[0]);
		cd >> n;
		cd.close();
		return;
	}
	void cdhs::in(long long& n, string name)
	{
		ifstream cd(&name[0]);
		cd >> n;
		cd.close();
		return;
	}
	void cdhs::in(bool& n, string name)
	{
		ifstream cd(&name[0]);
		cd >> n;
		cd.close();
		return;
	}
	void cdhs::in(char& n, string name)
	{
		ifstream cd(&name[0]);
		cd >> n;
		cd.close();
		return;
	}
	void cdhs::in(string& n, string name)
	{
		ifstream cd(&name[0]);
		cd >> n;
		cd.close();
		return;
	}

	//函数
	bool axj(long long key)
	{
		return (GetKeyState(key) < 0);
	}
	void bout(string n, long long s = 50, bool f = 0, char key = 13)//输出
	{
		for (long long i = 0; i < n.size(); i++)
		{
			if (f && GetKeyState(key) < 0)
			{
				cout << n.substr(i, n.size());
				return;
			}
			cout << n[i];
			Sleep(s);
		}
		return;
	}

	void gckdx(short h, short l)//设置窗口大小
	{
		string n = "mode con cols=", t = "";
		while (l > 0)
		{
			t = t + char(l % 10 + '0');
			l /= 10;
		}
		for (short i = t.size() - 1; i >= 0; i--)
		{
			n = n + t[i];
		}
		n = n + " lines=", t = "";
		while (h > 0)
		{
			t = t + char(h % 10 + '0');
			h /= 10;
		}
		for (short i = t.size() - 1; i >= 0; i--)
		{
			n = n + t[i];
		}
		system(&n[0]);
		return;
	}
	void gckm(string n)//修改窗口名称
	{
		string t = "title ";
		t += n;
		system(&t[0]);
		return;
	}
	hl sbwz(bool x = 1, bool n = 1)//鼠标位置
	{
		HANDLE hOutput = GetStdHandle(STD_OUTPUT_HANDLE);
		HWND h = GetForegroundWindow();
		CONSOLE_FONT_INFO consoleCurrentFont;
		hl hl;
		POINT p;
		if (x)
		{
			GetCursorPos(&p);
			ScreenToClient(h, &p);
		}
		else
		{
			GetCursorPos(&p);
		}
		if (n)
		{
			GetCurrentConsoleFont(hOutput, FALSE, &consoleCurrentFont);
			p.x /= consoleCurrentFont.dwFontSize.X;
			p.y /= consoleCurrentFont.dwFontSize.Y;
		}
		hl.h = p.y + 1;
		hl.l = p.x + 1;
		return hl;
	}
	void yanse(int n)//颜色
	{
		SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), n);
		return;
	}
	void ycbj()//移除快速编辑模式
	{
		HANDLE hStdin = GetStdHandle(STD_INPUT_HANDLE);
		DWORD mode;
		GetConsoleMode(hStdin, &mode);
		mode &= ~ENABLE_QUICK_EDIT_MODE;
		SetConsoleMode(hStdin, mode);
		return;
	}
	void ycgb()//隐藏光标
	{
		CONSOLE_CURSOR_INFO cursor;
		cursor.bVisible = FALSE;
		cursor.dwSize = sizeof(cursor);
		HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE);
		SetConsoleCursorInfo(handle, &cursor);
		return;
	}
	void ydgb(long long h, long long l)//移动光标
	{
		COORD pos = { l - 1,h - 1 };
		HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);
		SetConsoleCursorPosition(hOut, pos);
		return;
	}
string name;
	char dt[15][30],yutu,fx,sj=60,sl[15][30];     //                      0 1 2 3
	int sdf1=8,sdf2=8,g=1,die,gw1=9,gw2=9,hp=10,gwhp=1;
	int pai = 400,ban = 200,ting = 128;
	int szt=0,gzt=0;
	int slsh=0;
	bool f=1;
	//合成
	int xz=5;
	bool tc=1;
	string q="      空",w="      空",e="      空";//[][][]
	string a="      空",s="      空",d="      空";//[][][]
	string z="      空",x="      空",c="      空";//[][][]
	void gotoxy(int x=0,int y=0)
{
	COORD c;
	c.X=x;
	c.Y=y;
	SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),c);
}




void _Clearscreen(int x,int y,int p){//清空坐标后p-1个字符(包括坐标上的字符)
	gotoxy(x-1,y);
	for(int i=1;i<=p;i++)cout<<' ';
}
void _Clearscreen(int p){//清空光标后p-1个字符(包括光标上的字符)
	printf("\b");
	for(int i=1;i<=p;i++)cout<<' ';
}
void _Clearscreen(bool flag=1){//清空屏幕
	if(flag==1){//双缓冲
		HANDLE hStdOut; CONSOLE_SCREEN_BUFFER_INFO csbi; DWORD count; DWORD cellCount; COORD homeCoords = { 0, 0 };
	    hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
	    if (hStdOut == INVALID_HANDLE_VALUE) return;
	    if (!GetConsoleScreenBufferInfo(hStdOut, &csbi)) return;
	    cellCount = csbi.dwSize.X *csbi.dwSize.Y;
	    if (!FillConsoleOutputCharacter(hStdOut, (TCHAR) ' ', cellCount, homeCoords, &count )) return;
	    if (!FillConsoleOutputAttribute(hStdOut, csbi.wAttributes, cellCount, homeCoords, &count )) return;
	    SetConsoleCursorPosition(hStdOut, homeCoords);
	}
	else if(flag==0){//单缓冲
		HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
	    COORD coordScreen = {0, 0};
	    SetConsoleCursorPosition( hConsole, coordScreen );
	}

}
	void color(int a)
{
	SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),a);
/*	1	深蓝色
	2	深绿色
	3	深青色
	4	深红色
	5	深粉色
	i	黄色
	7	深白色
	8	灰色
	9	浅蓝色
	10	浅绿色
	11	浅青色
	12	浅红色
	13	浅粉色
	14	浅黄色
	15	浅白色
	背景
	1~15		黑色
	16~31		深蓝色
	32~47		深绿色
	48~63		深青色
	64~79		深红色
	'S'~95		深粉色
	96~111		深黄色
	112~127 	深白色
	128~143 	灰色
	144~159 	浅蓝色
	160~1'A' 	浅绿色
	176~191 	浅青色
	192~207 	浅红色
	208~223 	浅粉色
	224~239 	浅黄色
	240~255 	浅白色
*/
}
void printf_red(const char *s)
{
    printf("\033[0m\033[1;31m%s\033[0m", s);
}

void printf_green(const char *s)
{
    printf("\033[0m\033[1;32m%s\033[0m", s);
}

void printf_yellow(const char *s)
{
    printf("\033[0m\033[1;33m%s\033[0m", s);
}

void printf_blue(const char *s)
{
    printf("\033[0m\033[1;34m%s\033[0m", s);
}

void printf_pink(const char *s)
{
    printf("\033[0m\033[1;35m%s\033[0m", s);
}

void printf_cyan(const char *s)
{
    printf("\033[0m\033[1;36m%s\033[0m", s);
}
void photo(char n){
	if(n=='r'){
		color(12);
		cout<<"■";
	}else if(n=='b'){
		color(1);
		cout<<"■";
	}else if(n=='y'){
		color(14);
		cout<<"■";
	}else if(n=='g'){
		color(10);
		cout<<"■";
	}else if(n=='w'){
		color(15);
		cout<<"■";
	}else if(n=='p'){
		color(13);
		cout<<"■";
	}else if(n=='k'){
		cout<<"  ";
	}
}
void photo_man(){
	if(name=="Dream"){
		//      1          2          3          4          5          6          7          8          9          10
		 photo('k');photo('k');photo('g');photo('g');photo('g');photo('g');photo('g');photo('g');cout<<endl;
		 photo('k');photo('k');photo('g');photo('g');photo('g');photo('g');photo('g');photo('g');cout<<endl;
		 photo('k');photo('k');photo('g');photo('g');photo('g');photo('g');photo('g');photo('g');cout<<endl;
		 photo('k');photo('k');photo('g');photo('g');photo('g');photo('g');photo('g');photo('g');cout<<endl;
		 photo('k');photo('k');photo('g');photo('g');photo('g');photo('g');photo('g');photo('g');cout<<endl;
		 photo('k');photo('k');photo('g');photo('g');photo('g');photo('g');photo('g');photo('g');cout<<endl;//head
		 photo('g');photo('g');photo('g');photo('w');photo('w');photo('w');photo('w');photo('g');photo('g');photo('g');cout<<endl;
		 photo('g');photo('g');photo('w');photo('w');photo('w');photo('w');photo('w');photo('w');photo('g');photo('g');cout<<endl;
		 photo('g');photo('g');photo('w');photo('k');photo('w');photo('k');photo('w');photo('w');photo('g');photo('g');cout<<endl;
		 photo('g');photo('g');photo('w');photo('w');photo('w');photo('w');photo('w');photo('w');photo('g');photo('g');cout<<endl;
		 photo('g');photo('g');photo('w');photo('w');photo('w');photo('w');photo('w');photo('w');photo('g');photo('g');cout<<endl;
		 photo('g');photo('g');photo('g');photo('w');photo('w');photo('w');photo('w');photo('g');photo('g');photo('g');cout<<endl;//body
		 photo('k');photo('k');photo('g');photo('g');photo('k');photo('k');photo('g');photo('g');photo('k');photo('k');cout<<endl;
		 photo('k');photo('k');photo('g');photo('g');photo('k');photo('k');photo('g');photo('g');photo('k');photo('k');cout<<endl;
		 photo('k');photo('k');photo('g');photo('g');photo('k');photo('k');photo('g');photo('g');photo('k');photo('k');cout<<endl;
		 photo('k');photo('k');photo('g');photo('g');photo('k');photo('k');photo('g');photo('g');photo('k');photo('k');cout<<endl;
		 photo('k');photo('k');photo('g');photo('g');photo('k');photo('k');photo('g');photo('g');photo('k');photo('k');cout<<endl;
		 photo('k');photo('k');photo('g');photo('g');photo('k');photo('k');photo('g');photo('g');photo('k');photo('k');cout<<endl;//feet
	}
}
void muzic_die(){
	_Clearscreen(f);
	cout<<"   你死了\n";
	cout<<"   "<<name<<"死于:";
	if(die==1){
		cout<<"发现地板是岩浆做的\n";

	}else if(die==2){
		cout<<name<<"掉出了这个世界\n";
	}else if(die==3){
		cout<<"被野怪吃掉了\n";
	}else if(die==4){
		cout<<"被摔死了\n";
	}else {
		cout<<"死了\n";
	}
	anniu jntm;//定义anniu类的变量
	jntm.csh(10,11,10,20,"< 重 生 >",240,7);//初始化按钮
	while(1){
		if(jntm.gx_ax()){
			break;
		}
	}
	hp=10;
	sdf1=8;
	sdf2=8;
	dt[8][8]=' ';
	_Clearscreen(f);
}
//
//struct BLOCK{
//	string u1,u2,d1,d2;
//	int ph,u1c,u2c,d1c,d2c;
//};
//BLOCK block[11]={
//    {"  ","  ","  ","  ",0,0,0,0,0},//空气0
//    {"■","■","■","■",1,8,8,8,8},//石头1
//    {"","","","",0,9,9,9,9},//水2
//	{"■","■","■","■",1,15,15,15,15},//圆石3
//	{"■","■","■","■",1,10,10,14,14},//草4
//	{"■","■","■","■",1,14,14,14,14},//土5
//	{"","","","",0,4,4,4,4},//岩浆6
//	{"|#","#|","|#","#|",1,14,14,14,14},//木头7
//	{"▓","▓","▓","▓",1,3,3,3,3},//树叶8
//	{"■","■","■","■",1,7,8,8,7},//深板岩9
//	{"▓","▓","▓","▓",1,15,15,15,15},//雪10
//};
void sc(){
		for(int i=0;i<15;i++){
for(int j=0;j<30;j++){
if(i==sdf1&&j==sdf2){
	color(15);
	if(fx=='w'){
		cout<<"上玩";
	}else if(fx=='s'){
		cout<<"下玩";
	}else if(fx=='a'){
		cout<<"左玩";
	}else if(fx=='d'){
		cout<<"右玩";
	}
	if(dt[i][j]=='~'){
		hp--;
		die=1;
	}
	if(hp==0){
		sdf1=8;
		sdf2=8;
	}
}else{
	if(1){
		if(dt[i+1][j]==' '||dt[i][j+1]==' '||dt[i][j-1]==' '||dt[i-1][j]==' '){
			if(dt[i][j]=='#'){
				color(8);
			cout<<"■■";
		}else if(dt[i][j]=='@'){
			color(7);
			cout<<"■■";
		}else if(dt[i][j]=='~'){
			color(4);
			cout<<"■■";
		}else if(dt[i][j]=='w'){
			printf_blue("");
		}else if(dt[i][j]=='c'){
			printf_green("^^^^");
		}else{
			color(8);
			cout<<dt[i][j]<<dt[i][j]<<dt[i][j]<<dt[i][j];
		}
		}else{
		cout<<"    ";
	}
	}else{
		if(dt[i+1][j]==' '||dt[i][j+1]==' '||dt[i][j-1]==' '||dt[i-1][j]==' '){
			if(dt[i][j]=='~'){
			printf_red("■■");
		}else if(dt[i][j]=='w'){
			printf_blue("");
		}else{
			color(8);
			cout<<dt[i][j]<<dt[i][j]<<dt[i][j]<<dt[i][j];
		}
	}else{

		cout<<"    ";
	}
	}
}
}
cout<<endl;
for(int j=0;j<30;j++){
if(i==sdf1&&j==sdf2){
	color(15);
	if(fx=='w'){
		cout<<"↑家";
	}else if(fx=='s'){
		cout<<"↓家";
	}else if(fx=='a'){
		cout<<"←家";
	}else if(fx=='d'){
		cout<<"→家";
	}
	}else{
	if(1){
		if(dt[i+1][j]==' '||dt[i][j+1]==' '||dt[i][j-1]==' '||dt[i-1][j]==' '){
		if(dt[i][j]=='#'){
			color(8);
			cout<<"■■";
		}else if(dt[i][j]=='@'){
			color(7);
			cout<<"■■";
		}else if(dt[i][j]=='~'){
			color(4);
			cout<<"■■";
		}else if(dt[i][j]=='w'){
			printf_blue("");
		}else if(dt[i][j]=='c'){
			printf_yellow("■■");
		}else{
			cout<<dt[i][j]<<dt[i][j]<<dt[i][j]<<dt[i][j];
		}
	}else{
		cout<<"    ";
	}
	}else{
		if(dt[i+1][j]==' '||dt[i][j+1]==' '||dt[i][j-1]==' '||dt[i-1][j]==' '){
			if(dt[i][j]=='~'){
			printf_red("■■");
		}else if(dt[i][j]=='w'){
			printf_blue("");
		}else{
			cout<<dt[i][j]<<dt[i][j]<<dt[i][j]<<dt[i][j];
		}
	}else{
		cout<<"    ";
	}
	}
}
}
cout<<endl;
}
	cout<<"早上\n";
	cout<<"按鼠标左键挖掘,按wasd上下左右行走,按鼠标右键放方块,\n有时候野怪懒得游泳,它只有1滴血\n玩家名称:"<<name<<"\n";
	cout<<"X:"<<sdf1<<"  Y:"<<sdf2<<"\n";
if(gwhp==0){
	cout<<"野怪意外死亡,已经跑走了\n";
}
if(sdf1<0||sdf1>=15||sdf2<0||sdf2>=30){
	hp=0;
	die=2;
}
for(int i=1;i<=hp;i++){ 
color(4); 
	cout<<"▓";
}
for(int i=hp;i<10;i++){ 
color(8); 
	cout<<"▓";
}
color(15);
if(hp==0){
	muzic_die();
}
cout<<endl;



if(hp==0){
	muzic_die();
}
}
void dz(){
	if(axj(W)){
			 		if(dt[sdf1+1][sdf2]!=' '||dt[sdf1+2][sdf2]!=' '&&szt!=2){
			 			if(dt[sdf1+1!=' '][sdf2]) {
			 			if(dt[sdf1-1][sdf2]==' '||dt[sdf1-1][sdf2]=='~'||dt[sdf1-1][sdf2]=='w'){
			 			sdf1--;
					 }
			 		}
					 _Clearscreen(f);
					 sc();
					 szt++;
					 szt%=3;
					 }fx='w';
			 	}else if(axj(S)){

			 			if(sl[sdf1+1!=' '][sdf2]) {
			 		if(dt[sdf1+1][sdf2]==' '||dt[sdf1+1][sdf2]=='~'||dt[sdf1+1][sdf2]=='w'){
					sdf1++;slsh++;
					 }
				}

				 fx='s';
				 die=4;
					 _Clearscreen(f);
					 sc();
				 }else if(axj(A)){
				 if(dt[sdf1][sdf2-1]==' '||dt[sdf1][sdf2-1]=='~'||dt[sdf1][sdf2-1]=='w'){
					 sdf2--;
					 }
					 fx='a';
					 _Clearscreen(f);
					 sc();
				 }else if(axj(D)){

				 if(dt[sdf1][sdf2+1]==' '||dt[sdf1][sdf2+1]=='~'||dt[sdf1][sdf2+1]=='w'){
					 sdf2++;
					 }


					 fx='d';
					 _Clearscreen(f);
					 sc();
				 }else if(axj(z_sb)){

						if(fx=='w'&&dt[sdf1-1][sdf2]!='~'&&dt[sdf1-1][sdf2]!='w'){
					dt[sdf1-1][sdf2]=' ';

				Sleep(250) ;
					}else if(fx=='s'&&dt[sdf1+1][sdf2]!='~'&&dt[sdf1+1][sdf2]!='w'){
				dt[sdf1+1][sdf2]=' ';
				Sleep(250) ;
					}else if(fx=='a'&&dt[sdf1][sdf2-1]!='~'&&dt[sdf1][sdf2-1]!='w'){
					dt[sdf1][sdf2-1]=' ';
				Sleep(250) ;

					}else if(fx=='d'&&dt[sdf1][sdf2+1]!='~'&&dt[sdf1][sdf2+1]!='w'){
					dt[sdf1][sdf2+1]=' ';
				Sleep(250) ;

					}



					sdf1%=15;
					sdf2%=30;
					_Clearscreen(f);
					sc();
				 }else if(axj(y_sb)){
				  if(fx=='w'){
					dt[sdf1-1][sdf2]='@';
					}else if(fx=='s'){
					dt[sdf1+1][sdf2]='@';
					}else if(fx=='a'){
					dt[sdf1][sdf2-1]='@';
					}else if(fx=='d'){
					dt[sdf1][sdf2+1]='@';
					}

					_Clearscreen(f);
					sc();
				 }
}
void gs(string n){
	cout<<n<<endl;
}
void csh(){
	printf_red(" ");
	system("mode con cols=120 lines=46");
	system("title YUTU和森林之客制作——沙盒游戏");
	_Clearscreen(f);
	  system("cls");//            00000000000000000000
	
	Sleep(1000);
	_Clearscreen(f);
	for(int i=0;i<15;i++){
		for(int j=0;j<30;j++){
				if(i==0){
					dt[i][j]='c';
				}else{
					dt[i][j]='#';
				}
				if(i<5){
					sl[i][j]=' ';
				}else if(i>5){
					sl[i][j]='#';
				}else{
					sl[i][j]='c';
				}
		}
	}
	dt[9][9]='~';
	dt[30][30]='~';
	dt[30][29]='~';
	dt[30][28]='~';
	dt[30][27]='~';
	dt[29][27]='~';
	dt[3][30]='~';
	dt[3][29]='~';
	dt[3][28]='~';
	dt[3][27]='~';
	dt[4][27]='~';
	dt[7][7]='w';
	dt[5][5]='w';
	dt[6][6]='w';
	dt[10][10]='w';
	dt[21][21]='w';
	dt[22][30]='w';
	dt[3][29]='w';
	dt[3][28]='w';
	dt[3][27]='w';
	dt[4][27]='w';
	dt[8][8]=' ';
	dt[10][9]=' ';dt[10][10]=' ';dt[10][11]=' ';dt[9][9]=' ';dt[9][10]='~';dt[9][11]='~';
}
void m(){// wdnwnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn7
	csh();
//	if (MessageBox(0, TEXT("开始游戏"), TEXT("game"), MB_OKCANCEL | MB_ICONINFORMATION) != IDOK)
//    {
//        MessageBox(0, TEXT("必须开始"), TEXT("开始开始"), MB_OK);
//
//    };
cout_sleep("YUTU制作:\n      c++沙盒小游戏\n      版本:1.06\n      未经允许,不可转载");
	cout<<"\n你的名字叫什么?\n";
	cin>>name;
	system("cls");
	sc();

		while(1){
if(gwhp==1){
			 if(gzt==125000-1){
			 
			 system("cls");
			 	if(dt[sdf1+1][sdf2]==' '){
			 	sdf1++;
			 	slsh++;
			 }else{
			 	if(slsh>2){
				 	hp-=slsh-2;
			 		slsh=0;
			 		die=4;
				 }
			 }
			 sc();
			 }
			 }else{
			 	gw1=4;
			 	gw2=2;
				gwhp=1;
			 }
			 dz();
			 sj++;
			 sj%=240;
			 gzt++;gzt%=125000;
}

}


int main(){
ycgb();//隐藏光标
	ycbj();//移除编辑模式
	m();
}

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值