问题标题: 一堆游戏

1
2
已解决
杨骐宇
杨骐宇
中级光能
中级光能

XY轻摸鱼游 戏发布!!

先是基于垃 圾大全逃离系列改版的XY爱跑酷

/*
由于文件较大,编译和运行时间可能较长,请耐心等待! 
■
□
其中color后面的0是背景色代号,A是前景色代号。各颜色代码如下: 
0=黑色 
1=蓝色 
2=绿色 
3=湖蓝色 
4=红色 
5=紫色 
6=** 
7=白色 
8=灰色 
9=淡蓝色 
A=淡绿色 
B=淡浅绿色 
C=淡红色 
D=淡紫色 
E=淡** 
F=亮白色 
#define KEY_DOWN(VK_NONAME) ((GetAsyncKeyState(VK_NONAME) & 0x8000) ? 1:0)
0=黑色,1=蓝色,2=绿色,3=湖蓝色,4=红色,5=紫色;
 
6=**,7=白色,8=灰色,9=淡蓝色,A=淡绿色,B=浅绿色;
 
C=淡红色,D=淡紫色,E=淡**,F=亮白色。
VK_LBUTTON             鼠标左键                      0x01
VK_RBUTTON             鼠标右键                      0x02
VK_CANCEL              Ctrl + Break                  0x03
VK_MBUTTON             鼠标中键                      0x04
 
VK_BACK                Backspace 键       0x08
VK_TAB                 Tab 键                        0x09
 
VK_RETURN              回车键                        0x0D
 
 
VK_SHIFT               Shift 键                      0x10
VK_CONTROL             Ctrl 键                       0x11
VK_MENU                Alt 键                 0x12
VK_PAUSE               Pause 键                      0x13
VK_CAPITAL             Caps Lock 键                  0x14
 
VK_ESCAPE              Esc 键                        0x1B
 
VK_SPACE               空格键         0x20
VK_PRIOR               Page Up 键                    0x21
VK_NEXT                Page Down 键                  0x22
VK_END                 End 键                        0x23
VK_HOME                Home 键                       0x24
VK_LEFT                左箭头键                      0x25
VK_UP                  上箭头键                      0x26
VK_RIGHT               右箭头键                      0x27
VK_DOWN                下箭头键                      0x28
VK_SNAPSHOT            Print Screen 键               0x2C
VK_Insert              Insert 键                     0x2D
VK_Delete              Delete 键                     0x2E
 
'0' – '9'             数字 0 - 9                    0x30 - 0x39
65 – 'Z'             字母 A - Z                    0x1 - 0x1
 
VK_LWIN                左WinKey(104键盘才有)         0x5B
VK_RWIN                右WinKey(104键盘才有)         0x5C
VK_APPS                AppsKey(104键盘才有)          0x5D
 
VK_NUMPAD0            小键盘 0 键                    0x60
VK_NUMPAD1            小键盘 1 键                    0x61
VK_NUMPAD2            小键盘 2 键                    0x62
VK_NUMPAD3            小键盘 3 键                    0x63
VK_NUMPAD4            小键盘 4 键                    0x64
VK_NUMPAD5            小键盘 5 键                    0x65
VK_NUMPAD6            小键盘 6 键                    0x66
VK_NUMPAD7            小键盘 7 键                    0x67
VK_NUMPAD8            小键盘 8 键                    0x68
VK_NUMPAD9            小键盘 9 键                    0x69
 
VK_F1 - VK_F24        功能键F1 – F24               0x70 - 0x87
 
VK_NUMLOCK            Num Lock 键                   0x90
VK_SCROLL             Scroll Lock 键                0x91
#include <iostream>
#include "windows.h"
using namespace std;
int main()
{
	cout << "原色testCOLOR(没有设置字体颜色)" << endl;
	SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED |
		FOREGROUND_GREEN | FOREGROUND_BLUE);//设置三色相加
	cout << "白色testCOLOR(红色绿色蓝色相加)" << endl;
	SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED);
	//设置红色
	cout << "红色testCOLOR(设置的颜色为红色)" << endl;
	SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_GREEN)
		;//设置绿色
	cout << "绿色testCOLOR(设置的颜色为绿色)" << endl;
	SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_BLUE);
	//设置蓝色
	cout << "蓝色testCOLOR(设置的颜色为蓝色)" << endl;
	SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED |
		FOREGROUND_GREEN);//设置红色和绿色相加
	cout << "**testCOLOR(红色和绿色相加色)" << endl;
	SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED |
		FOREGROUND_BLUE);//设置红色和蓝色相加
	cout << "粉色testCOLOR(红色和蓝色相加色)" << endl;
	SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_GREEN |
		FOREGROUND_BLUE);//设置绿色和蓝色相加
	cout << "青色testCOLOR(绿色和蓝色相加色)" << endl;
	SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY);
	//设置颜色,没有添加颜色,故为原色
	cout << endl;
	system("pause");
	return 0;
}
*/ 
#include<bits/stdc++.h>
#include<time.h>
#include<windows.h>
#include<conio.h>
#include<cstdio>
#pragma GCC optimize(3)
#pragma GCC target("avx")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("inline")
#pragma GCC optimize("-fgcse")
#pragma GCC optimize("-fgcse-lm")
#pragma GCC optimize("-fipa-sra")
#pragma GCC optimize("-ftree-pre")
#pragma GCC optimize("-ftree-vrp")
#pragma GCC optimize("-fpeephole2")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("-fsched-spec")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-falign-jumps")
#pragma GCC optimize("-falign-loops")
#pragma GCC optimize("-falign-labels")
#pragma GCC optimize("-fdevirtualize")
#pragma GCC optimize("-fcaller-saves")
#pragma GCC optimize("-fcrossjumping")
#pragma GCC optimize("-fthread-jumps")
#pragma GCC optimize("-funroll-loops")
#pragma GCC optimize("-fwhole-program")
#pragma GCC optimize("-freorder-blocks")
#pragma GCC optimize("-fschedule-insns")
#pragma GCC optimize("inline-functions")
#pragma GCC optimize("-ftree-tail-merge")
#pragma GCC optimize("-fschedule-insns2")
#pragma GCC optimize("-fstrict-aliasing")
#pragma GCC optimize("-fstrict-overflow")
#pragma GCC optimize("-falign-functions")
#pragma GCC optimize("-fcse-skip-blocks")
#pragma GCC optimize("-fcse-follow-jumps")
#pragma GCC optimize("-fsched-interblock")
#pragma GCC optimize("-fpartial-inlining")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("-freorder-functions")
#pragma GCC optimize("-findirect-inlining")
#pragma GCC optimize("-fhoist-adjacent-loads")
#pragma GCC optimize("-frerun-cse-after-loop")
#pragma GCC optimize("inline-small-functions")
#pragma GCC optimize("-finline-small-functions")
#pragma GCC optimize("-ftree-switch-conversion")
#pragma GCC optimize("-foptimize-sibling-calls")
#pragma GCC optimize("-fexpensive-optimizations")
#pragma GCC optimize("-funsafe-loop-optimizations")
#pragma GCC optimize("inline-functions-called-once")
#pragma GCC optimize("-fdelete-null-pointer-checks")
#pragma GCC optimize(2)
#define get(VK_NONAME) (GetAsyncKeyState(VK_NONAME))
#define clean (system("cls"))
#define sl(x) (Sleep(x))
//格式1:上次游玩得分 最高得分 
//格式2: 上次日期(年月日) 上次游玩累计时间(分钟) {以后建} 
//地图 :7*100    0:空   1,正常方块   
//△:你 
//×:危险方块 
using namespace std;
void color(int corcorcor){
    SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),corcorcor);
    
/*	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~165 	浅绿色
	176~191 	浅青色
	192~207 	浅红色
	208~223 	浅粉色
	224~239 	浅**
	240~255 	浅白色
*/

}
int kais,zg,chose;
HWND hwnd=GetForegroundWindow();
int zgt;
int x,y,er=-5,jl,erc,jlc; 
int df;
int getcc=0; 
int dt[7][190]={
{0,0,0,0,0,0,0,0,0,0,0,0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(tmp, sizeof(tmp), "%Y-%m-%d",localtime(&timep) );
    
}
void cls(){
    HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
    COORD coordScreen = { 0, 0 };
    SetConsoleCursorPosition( hConsole, coordScreen );
}
void HideCursor(){
	HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE);
	CONSOLE_CURSOR_INFO CursorInfo;
	GetConsoleCursorInfo(handle, &CursorInfo);
	CursorInfo.bVisible = false;
	SetConsoleCursorInfo(handle, &CursorInfo);
}
void out(string s){
	for(int i=0;i<s.size();i++){
		cout<<s[i];
		Sleep(25);
	}
	cout<<"\n";	
}
void quicklyout(string s){
	for(int i=0;i<s.size();i++){
		cout<<s[i];
		Sleep(20);
	}
	cout<<"\n";
}
void getz(){
	while(1){
		if(get(0x1)){
			clean;
			break;
		}
		if(get(0x43)){
			clean;
			getcc=1;
			break;
		}
	}
}
void goin(){
	system("mode con cols=50 lines=10");  
	mciSendString("play music/mus_date_tense.mp3 repeat", 0, 0, 0);  
	out("一觉醒来,你竟发现\n你来到了二维世界!\n\n按Z继续\n按C跳过");
	getz();
	if(getcc==1)return ;
	out("你正准备好好看看二维世界时,\n三维空间忽然坍塌向二维空间坍塌了!\n于是......\n你开始了逃亡......\n\n按Z继续\n");
	getz();
}
int change(string s){
	int f=1,idx=0;
	for(int i=s.size()-1;i>=0;i--){
		idx+=(s[i]-'0')*f;
		f*=10;
	}
	return idx;
}           
void getkz(){//摘自luckyone906的博客 
	ifstream fin("txt/1.txt");
	fin>>y>>x>>er>>zg;
	fin.close();
	if(y==0&&x==0&&er==0&&zg==0){
		er=-5;
		x=4;
		y=0;
	}
}
int qh=144; 
void prin(){
	cls();
	cout<<"      ————游戏得分"<<left << setw(6) << zgt<<"————\n";
	for(int i=0;i<=6;i++){
		for(int j=y-5;j<=-1;j++){
			if(j<=er){
				SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED);
				cout<<" ╳ ";	
				SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY);
			}
			else{
				color(2);
				//SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_BLUE);
				cout<<"██";
				SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY);
			}
		}
		for(int j=max(0,y-5);j<=min(190,y+5);j++){
			if(dt[i-1][j]==1){
				if(dt[i][j]==1){	
					color(2);
					//SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_BLUE);
					cout<<"██";
					SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY);
				}
				else{
					color(6);
					//SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_BLUE);
					cout<<"██";
					SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY);
				}
			}else if(j<=er){
				SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED);
				cout<<" ╳ ";	
				SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY);
			}
			else if(x==i&&y==j){
				SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED |FOREGROUND_GREEN);
				cout<<"你";
				SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY);
			}
			else if(dt[i][j]==0){
				color(9);
				cout<<"██";
				SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY);
			}
			else if(dt[i][j]==5){
				cout<<"尽";
			}else if(dt[i][j]==6){
				cout<<"情";
			} else if(dt[i][j]==7){
				cout<<"期";
			} else if(dt[i][j]==8){
				cout<<"待";
			} 
			else{
				
				color(2);
				//SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_BLUE);
				cout<<"██";
				SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY);
			}
		}
		cout<<"\n";
	}
}//
void shiyong(){
	if(getcc==1){
		mciSendString("stop music/mus_date_tense.mp3", 0, 0, 0);  
		return ;
	}
	out("操作须知:\n按ad键左右选择,按Z确认选择。\n按X结束游戏。\n按w/s/a/d移动");
	SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED |FOREGROUND_GREEN);
	cout<<"△";
	SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY);
	out(":你   ");
	SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED);
	cout<<"×";	
	SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY);
	out(":危险方块  ");
	SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_BLUE);
	cout<<"██";
	SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY);
	out("普通方块\n按Z继续");
	/* 
	SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_BLUE);
	cout<<"■";
	SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY);
	SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED |FOREGROUND_GREEN);
	cout<<"△";
	SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY);
	SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED);
	cout<<"×";	
	SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY);
	*/
	getz();
	mciSendString("stop music/mus_date_tense.mp3", 0, 0, 0);  
}
int suum=0;
void mainchose(){
	mciSendString("play music/mus_menu1.mp3 repeat", 0, 0, 0);  
	zg=max(zg,zgt);
	chose=1;
	int tf=1;
	while(1){
		bool f=0;
		if(get(90)) break;
		if(tf==1){
			tf=0;
			f=1;
		}
		if(get(65)){
			if(chose==2){
				chose=1;
				f=1;
			}
		}
		if(get(68)){
			if(chose==1){
				chose=2;
				f=1;
			}
		}
		if(f==1&&chose==1){
			clean;
			cout<<"---------------------------------\n"
				<<"|         最高分:"<< left << setw(6) << zg<<"        |\n";
			SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED |FOREGROUND_GREEN);
			cout<<"------------------";
			SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY);
			cout<<"---------------\n";
			SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED |FOREGROUND_GREEN);
			cout<<"|  继续上次游戏  |";
			SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY);
			cout<<"    新 游 戏  |\n";
			SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED |FOREGROUND_GREEN);
			cout<<"------------------";
			SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY);
			cout<<"---------------\n";
			SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_BLUE);
			cout<<"               逃离"; 
			SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY);
			cout<<"贡献榜:\n";
			SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_GREEN |FOREGROUND_BLUE);
			cout<<"            吴庞茂旭 吕若朴";
			SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY);
			
		}
		if(f==1&&chose==2){
			clean;
			cout<<"---------------------------------\n"
				<<"|         最高分:"<< left << setw(6) << zg<<"        |\n";
			cout<<"-----------------";
			SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED |FOREGROUND_GREEN);
			cout<<"----------------\n";
			SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY);
			cout<<"|  继续上次游戏  ";
			SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED |FOREGROUND_GREEN);
			cout<<"|    新 游 戏  |\n";
			SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY);
			cout<<"-----------------";
			SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED |FOREGROUND_GREEN);
			cout<<"----------------\n";
			SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_BLUE);
			cout<<"               逃离"; 
			SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY);
			cout<<"贡献榜:\n";
			SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_GREEN |FOREGROUND_BLUE);
			cout<<"            吴庞茂旭 吕若朴";
			SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY);
			
		}
		sl(10);
		
	} 
	mciSendString("stop music/mus_menu1.mp3", 0, 0, 0);  
}
int choseagain(){
	int chosea=1,tf=1;
	while(1){
		if(get(90))break;
		bool f=0;
		if(tf==1){
			tf=0;
			f=1;
		}
		if(get(65)){
			if(chosea==2){
				chosea=1;
				f=1;
			}
		}
		if(get(68)){
			if(chosea==1){
				chosea=2;
				f=1;
			}
		}
		if(f==1&&chosea==1){
			clean;
			SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED |FOREGROUND_GREEN);
			cout<<"   yes   ";
			SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY);
			cout<<"   no";
		}
		if(f==1&&chosea==2){
			clean;
			SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY);
			cout<<"   yes   ";
			SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED |FOREGROUND_GREEN);
			cout<<"   no";
			SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY);
		}
		sl(10);
	} 
	return chosea;
}
void goout(int x){
	if(x==1){//摘自 浅浅的 的微博 
		ofstream fout("txt/1.txt");
		fout<<0<<" "<<4<<" "<<-5<<" "<<max(zg,zgt);
		/*fout << flush;*/ 
		fout.close();
	}
	else{
		freopen("txt/1.txt","w",stdout);
		cout<<y<<" "<<x<<" "<<er<<" "<<max(zg,zgt);
		fclose(stdout);
	}
}
void Main1(){
	/*cout<<"---------------------------------\n"
		<<"|         最高分:"<< left << setw(6) << zg<<"        |\n"
		<<"---------------------------------\n"
	    <<"|  继续上次游戏  |    新 游 戏  |\n"
	    <<"---------------------------------\n";*/
	getkz();
	sl(1000);
	erc=0;
	jlc=0;
	mainchose();
	if(chose==2){
		er=-5;
		x=4;
		y=0;
	}
	clean;
	cout<<"请选择模式:\n|   1.无限模式   |   2.100格  |\n请输入数字:";
	int queding;
	int qd;
	Sleep(2000);
	cin>>qd;
	if(qd==1){
		queding=0;
	}else{
		queding=1;
	}
	clean;
	zgt=0;
	SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED |FOREGROUND_GREEN);
	out("---———3");
	sl(1000);
	clean;
	out("--———2");
	sl(1000);
	clean;
	out("-———1");
	sl(1000);
	clean;
	out("      开始!");
	sl(500);
	SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY);
	mciSendString("stop music/mus_menu1.mp3", 0, 0, 0);  
	mciSendString("play music/mus_ruins.mp3 repeat", 0, 0, 0);  
	int yf;
	int tget=0; 
	prin();
	while(1){
		char cmmd=kbhit();
		if(tget==3)tget=0;
		zgt=max(zgt,y);
		df=y;
		if(get('X')){
			yf=2;
			break;
		}
		if(y<=er){
			yf=0;
			break;
		}
		erc++;
		if(dt[x+1][y]==0)jlc++;
		if(erc==10){
			er++;
			erc=1;
			prin();
		}
		if(y>=100&&x==4&&queding==1){
			prin();
			yf=1;
			break;
		}
		if(x==6){
			x++;
			sl(100);
			prin();
			sl(100);
			clean;
			yf=-1;
			break;
		}
		if(dt[x+1][y]==0&&jlc==6){
			x++;
			jlc=0;
			prin();
		}
		if(get(65)&&dt[x][y-1]==0&&tget==2){
			y--;
			prin();
		}
		if(dt[x+1][y]==1&&get(87)&&tget==2){
			int jian;
			for(jian=1;jian<=6-x;jian++){
				if(dt[x-jian][y]==1){
					jian--;
					break;
				}
			}
			x-=jian;
			x=max(x,0);
			prin();
		}
		if(get(68)&&dt[x][y+1]==0&&tget==2){
			y++;
			prin();
		}
		sl(40);
		tget++;
		/*VK_LEFT                左箭头键                      0x25
		VK_UP                  上箭头键                      0x26
		VK_RIGHT               右箭头键                      0x27
		VK_DOWN                下箭头键                      0x28*/
	}
	mciSendString("stop music/mus_ruins.mp3", 0, 0, 0);  
	if(yf==-1){
		out("你掉入了虚空......");
		sl(1000); 
		goout(1);
		clean;
		out("要再来一次吗?");
		if(choseagain()==1){
			sl(500); 
			Main1();
		}
		else{
			clean;
			//cout<<"再会!"; 
			//sl(500);
			ShowWindow(hwnd,0); 
			return ;
		}
	}
	else if(yf==0){
		clean;
		out("你被三维化了......") ;
		goout(1);
		sl(1000); 
		clean;
		out("要再来一次吗?");
		if(choseagain()==1){
			sl(500); 
			Main1();
		}
		else{
			clean;
		//	cout<<"再会!"; 
		//	sl(500);
			ShowWindow(hwnd,0); 
			return ;
		}
	}
	else if(yf==1&&queding==1){
		sl(1000);
		clean;
		out("不知怎么了,你就来到了宇宙的边缘\n忽然,你看到了一条裂缝......\n\n   (未完待续)");
		goout(1);
		int mb=MessageBox(NULL,"还要再次游戏吗?","XY游戏管家",MB_YESNO || MB_ICONINFORMATION);
		if(mb==7){
			sl(2000);
			ShowWindow(hwnd,0); 
		}else{
			system("cls");
			SetConsoleTitle("逃离系列1:新的希望"); 
			system("color 0A");
			HideCursor();
			SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY);
			goin();
			shiyong();
			sl(500); 
			Main1();
		}
	}
	else{
		goout(2);
		ShowWindow(hwnd,0);
	}
}
int main(){
	SetConsoleTitle("逃离系列1:新的希望"); 
	system("color 0A");
	HideCursor();
	SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY);
	goin();
	shiyong();
	sl(500); 
	Main1();
	return 0;
}

操作须知:

按ad键左右选择,

按Z确认选择。

按X结束游戏。

按w/s/a/d移动

 

 

———————————————————————————————————————————————————

 

 

下面是XY小船求生

#include <bits/stdc++.h>
#include <cstdlib>
#include <time.h>
#include <cmath>
#include <iostream>
#include <fstream>
#include <unistd.h>
#include<conio.h>
#include<windows.h>
bool isLinux033=0;
using namespace std;
void color(int corcorcor){
    SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),corcorcor);
    
/*	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~165 	浅绿色
	176~191 	浅青色
	192~207 	浅红色
	208~223 	浅粉色
	224~239 	浅**
	240~255 	浅白色
*/

}
void cls(){
    HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
    COORD coordScreen = { 0, 0 };
    SetConsoleCursorPosition( hConsole, coordScreen );
}
long long h=19,l=1,w=0,xp=0;

//' '=水,'P'=玩家,'W'=木板



char setting_a[1024][1024];

int player_x=511;
int player_y=511;
int clsgood=0;
int player_d='W';
int main(){
	
	system("mode con cols=40 lines=15");  
    setting_a[511][511]='P';
    setting_a[511][512]='W';
    setting_a[512][511]='W';
    setting_a[512][512]='W';
    srand(time(NULL));
    FIRST:
    cout<<"欢迎来到XY轻游戏:小船求生"<<endl;
    Sleep(1000); 
	goto **;
    **:
    int setting_difficulty;
    int setting_maxx;
    int setting_maxy;
    setting_maxx=5;
    setting_maxy=5;
    setting_difficulty=1;
    setting_difficulty+=20;
    int iswin=0;
    int ans;
    system("cls");
    while(h>0){
    	if(clsgood==0){
    		
    	cls(); 
		}else{
			system("cls");
			clsgood=0;
		}
        ans++;
        if(l>63){
            iswin++;
            break;
        }
        
        h++;
        if(xp/l>0){
            l+=xp/l;
            xp=(xp+1)%l;
        }
        cout<<endl;
        for(int i=player_x-setting_maxx;i<player_x+setting_maxx;i++){
            for(int j=player_y-setting_maxy;j<player_y+setting_maxy;j++){
                if((i==player_x-setting_maxx || i==player_x+setting_maxx-1)|| (j==player_y-setting_maxy || j==player_y+setting_maxy-1)){
                    if(rand()%setting_difficulty==0){
                        if(setting_a[i][j]=='\0'){
                            setting_a[i][j]='w';
                        }
                    }
                }
                switch(setting_a[i][j]){
                    case 'W':
                        if(isLinux033) cout<<"\033[31;43m";  
				color(9);
                        cout<<"船"; 
				SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY);
                        if(isLinux033) cout<<"\033[0m";
                        break;
                    case '\0':
                        color(9);
				cout<<"██";
				SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY);
                        break;
                    case 'P':
                        if(isLinux033) cout<<"\033[7m";
                        cout<<"你";
                        if(isLinux033) cout<<"\033[0m";
                        break;
                    case 'w':
                        if(isLinux033) cout<<"\033[33;44m";
                        color(2);
                        cout<<"██";
				SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY);
                        if(isLinux033) cout<<"\033[0m";
                        break;
                    default:
                        if(isLinux033) cout<<"\033[45m";
                        cout<<"██";
                        if(isLinux033) cout<<"\033[0m";
                        break;
                }
            }
            cout<<endl;
        }
        for(int i=0;i<2*setting_maxx;i++){
            cout<<"_";
        }
        if(player_d=='\0'){
            cout<<endl<<"您正在消耗体力,请尽快回到木筏上回血!";
            h-=1;
            
        }
        if(player_d!='\0'){
        	clsgood=1;
            
        }
        if(player_d=='w'){
            cout<<endl<<"您获得了一块木头!";
            player_d='\0';
            w++;
            clsgood=1;
        }
        cout<<endl<<"血量:"<<h<<" 木头数量:"<<w<<" 等级:"<<l<<" 时间:"<<ans;
        char tmp='\0';
        while(tmp=='\0'){
            tmp=getch();
            switch(tmp){
                case 'w':
                    setting_a[player_x][player_y]=player_d;
                    player_x--;
                    player_d=setting_a[player_x][player_y];
                    setting_a[player_x][player_y]='P';
                    break;
                case 'W':
                    setting_a[player_x][player_y]=player_d;
                    player_x--;
                    player_d=setting_a[player_x][player_y];
                    setting_a[player_x][player_y]='P';
                    break;
                case 'a':
                    setting_a[player_x][player_y]=player_d;
                    player_y--;
                    player_d=setting_a[player_x][player_y];
                    setting_a[player_x][player_y]='P';
                    break;
                case 'A':
                    setting_a[player_x][player_y]=player_d;
                    player_y--;
                    player_d=setting_a[player_x][player_y];
                    setting_a[player_x][player_y]='P';
                    break;
                case 's':
                    setting_a[player_x][player_y]=player_d;
                    player_x++;
                    player_d=setting_a[player_x][player_y];
                    setting_a[player_x][player_y]='P';
                    break;
                case 'S':
                    setting_a[player_x][player_y]=player_d;
                    player_x++;
                    player_d=setting_a[player_x][player_y];
                    setting_a[player_x][player_y]='P';
                    break;
                case 'd':
                    setting_a[player_x][player_y]=player_d;
                    player_y++;
                    player_d=setting_a[player_x][player_y];
                    setting_a[player_x][player_y]='P';
                    break;
                case 'D':
                    setting_a[player_x][player_y]=player_d;
                    player_y++;
                    player_d=setting_a[player_x][player_y];
                    setting_a[player_x][player_y]='P';
                    break;
                case 'p':
                    if(w>0 && player_d!='W'){
                        player_d='W';
                        w--;
                        xp++;
                    }
                    break;
                case 'P':
                    if(w>0 && player_d!='W'){
                        player_d='W';
                        w--;
                        xp++;
                    }
                    break;
            }
        }
    }
    if(iswin==0){
        cout<<"\n您因为没有体力而被水淹没了!";
        return 0;
    }
    else{
        cout<<"防假速通验证码."<<setting_difficulty*ans+pow(ans%3+2,setting_difficulty%10)<<".";
        cout<<"\n您通关了!您的难度为:"<<setting_difficulty-20<<" 您的用时为:"<<ans<<"帧";
    } 
    return 0;
}

绿色的是木头(doge)

蓝色的是水 

 

 

 

 

——————————————————————————————————————————————————

 

下面是XY棒球小游戏

 

#include <iostream>
#include <stdlib.h>
#include <time.h>
#include<conio.h>
#include<windows.h>

using namespace std;
void color(int corcorcor){
    SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),corcorcor);
    
/*	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~165 	浅绿色
	176~191 	浅青色
	192~207 	浅红色
	208~223 	浅粉色
	224~239 	浅**
	240~255 	浅白色
*/

}
void cls(){
    HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
    COORD coordScreen = { 0, 0 };
    SetConsoleCursorPosition( hConsole, coordScreen );
}
int main() {
    srand(time(NULL));  // 初始化随机数发生器

    int score = 0;      // 得分
    int life = 3;       // 生命值
    int speed = 1;      // 小球初始速度
    int pos = rand() % 10 + 1;  // 小球初始位置
    int bat_pos = 5;    // 球拍位置

    cout << "欢迎来到XY接球小游戏!" << endl;
    cout << "按'a'或'd' 让球或者拍子左右移动" << endl;
    cout << "你有3条命,准备好了吗?" << endl;
    cout << "o=球      |=拍子" << endl;
    cout << "按w结束" << endl;
    cout << endl;
	Sleep(1000);
	system("cls"); 
    while (life > 0) {  // 游戏主循环
        // 显示当前状态
        cls();
        if(getch()=='w'&&getch()=='W'){
			return 0;
		}
       // cout << "得分: " << score << "    命: " << life << endl;
        for (int i = 1; i <= 10; i++) {
            if (i == bat_pos) {
            	color(32);
                cout << "|";  // 显示球拍
				SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY);

            } else if (i == pos) {
            	color(63); 
                cout << "o";  // 显示小球
				SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY);

            } else {
      
                cout << " ";  // 显示空格
            }
        }
        cout<< endl<<"______________"<<endl<< "得分: " << score << "    命: " << life ;

        // 等待玩家输入
        char input;
        input=getch();
		if(input=='w'&&input=='W'){
			return 0;
		}
        // 移动球拍
        if (input == 'a' && bat_pos > 1) {
            bat_pos--;
        } else if (input == 'd' && bat_pos < 10) {
            bat_pos++;
        }

        // 移动小球
        pos += speed;

        // 小球撞到墙壁
        if (pos == 1 || pos == 10) {
            speed = -speed;  // 反弹
        }

        // 小球落地
        if (pos == 11) {
            life--;          // 生命值减一
            pos = rand() % 10 + 1;  // 重新随机位置
            speed = 1;       // 速度重置
        }

        // 接住小球
        if (pos == bat_pos) {
            score++;         // 得分加一
            pos = rand() % 10 + 1;  // 重新随机位置
            speed++;         // 速度加一
        }
    }

    // 游戏结束
    cout << "Game over! You are dead! forever! " << endl;
    cout << "Your final score is: " << score << endl;
    return 0;
}

“ | ”是拍子,你用a和d操控拍子,然后碰到球(o)

如果欢迎后一片空白,按a和d

 

杨骐宇在2023-04-05 19:20:48追加了内容

茄子!


0
0
0
薛乘志
薛乘志
初级启示者
初级启示者

真的,别上火车头了,没用的,更可能负优化

开个O2足够了

0
刘风翔
刘风翔
新手启示者
新手启示者

小船求生的代码有些问题:

**=???

0
我要回答