DEVC++4399泡泡堂小游戏一周年庆兼火灾现场地图更新

#include<algorithm>
#include<fstream>
#include<iostream>
#include<stdio.h>
#include<cstdio>
#include<iostream>
#include<windows.h>
#include<conio.h>
#include <time.h>
#include <stdlib.h>
using namespace std; //O炸弹,绿1P红2P,地图:5*5
int x1,y1,x2,y2;
int b1x=-2,b1y=-2;
int b2x=-2,b2y=-2;
int x,y,z;
int cn;
int dsr;
int boom_time;
int boom_time2;
int open() {
	system("cls");
	SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_GREEN);
	cout<<"					    4399泡泡堂(简化版)"<<endl;
	cout<<"复刻:黑客小C"<<endl;
	cout<<endl;
	cout<<endl;
	cout<<endl;
	cout<<endl;
	cout<<endl;
	cout<<endl;
	cout<<endl;
	cout<<endl;
	cout<<endl;
	cout<<endl;
	cout<<endl;
	cout<<endl;
	cout<<endl;
	cout<<endl;
	cout<<endl;
	cout<<endl;
	cout<<endl;
	cout<<endl;
	cout<<endl;
	cout<<endl;
	cout<<endl;
	cout<<endl;
	cout<<"当前赛季:SSS"<<z<<endl;
	cout<<"规则:1p:wasd移动f放泡泡,2p:ikj移动lh放泡泡"<<endl;
	cout<<"按1进入黄金沙漠,按2进入青青草原,按3进入神秘星系,按4进入火灾现场";
	char c;
	while(c!='1'&&c!='2'&&c!='3') {
		while(!kbhit()) {

		}
		c=getch();
		if(c=='1') {
			cn=1;
		}
		if(c=='2') {
			cn=2;
		}
		if(c=='3') {
			cn=3;
		}
		if(c=='4'){
			cn=4;
		}
	}
}
int out() {
	system("cls");
	cout<<endl;
	cout<<endl;
	cout<<endl;
	cout<<endl;
	cout<<endl;
	cout<<endl;
	cout<<endl;
	for(int i=-1; i<6; i++) {
		for(int j=-2; j<6; j++) {
			if(i>=1&&i<=3&&j>=1&&j<=3) {
				if(cn==1) {
					SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_GREEN);
					cout<<"*";
				} else if(cn==2) {
					SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_GREEN);
					cout<<"*";
				} else if(cn==3) {
					SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_BLUE);
					cout<<"*";
				} else if(cn==4){
					SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED);
					cout<<"*";
				}
			} else if(j==-2) {
				cout<<"					";
			} else if(i==-1||i==5) {
				SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED| FOREGROUND_BLUE|FOREGROUND_GREEN);
				cout<<"*";
			} else if(j==-1||j==5) {
				SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED| FOREGROUND_BLUE|FOREGROUND_GREEN);
				cout<<"*";
			} else if(i==x1&&j==y1) {
				SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_GREEN);
				cout<<"*";
			} else if(i==x2&&j==y2) {
				SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED);
				cout<<"*";
			} else if(i==b1x&&j==b1y) {
				SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_BLUE);
				cout<<"O";
			} else if(i==b2x&&j==b2y) {
				SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_BLUE);
				cout<<"O";
			} else {
				cout<<" ";
			}
		}
		cout<<endl;
	}
}
int play() {
	char p1;
	if(kbhit()) {
		p1=getch();
		if(p1=='w'&&x1>0) {
			x1--;
		}
		if(p1=='a'&&y1>-1) {
			y1--;
		}
		if(p1=='s'&&x1<5) {
			x1++;
		}
		if(p1=='d'&&y1<5) {
			y1++;
		}
		if(p1=='f') {
			b1x=x1;
			b1y=y1;
			boom_time=10;
		}
		if(p1=='i'&&x2>0) {
			x2--;
		}
		if(p1=='j'&&y2>0) {
			y2--;
		}
		if(p1=='k'&&x2<5) {
			x2++;
		}
		if(p1=='l'&&y2>5) {
			y2++;
		}
		if(p1=='h') {
			b2x=x2;
			b2y=y2;
			boom_time2=10;
		}
	}
	if(x1<0) {
		x1=0;
	}
	if(x2<0) {
		x2=0;
	}
	if(x1>4) {
		x1=4;
	}
	if(x2>4) {
		x2=4;
	}
	if(y1<0) {
		x1=0;
	}
	if(y2<0) {
		x2=0;
	}
	if(y1>4) {
		x1=4;
	}
	if(y2>4) {
		x2=4;
	}
}
int main() {
	SYSTEMTIME sys;
	GetLocalTime(&sys);
	time_t now=time(0);
	tm *gmtm = gmtime(&now);
	tm *ltm = localtime(&now);
	y=1900 + ltm->tm_year;
	x=1 + ltm->tm_mon;
	z=y-2022;
	z*=4;
	system("cls");
	if(x>=1&&x<=3) {
		z+=1;
	}
	if(x>=4&&x<=6) {
		z+=2;
	}
	if(x>=7&&x<=9) {
		z+=3;
	}
	if(x>=10&&x<=12) {
		z+=4;
	}
	char f;
	while(true) {
		system("cls");

		b1x=-1;
		b1y=-2;
		b2x=-2;
		b2y=-2;
		if(f=='o') {
			break;
		}
		open();
		x1=0;
		y1=0;
		x2=4;
		y2=4;
		while(true) {
			out();
			play();
			if(((b1x==x2||b1y==y2)&&boom_time==0)||((b2x==x2&&b2y==y2)&&boom_time2==0)) {
				system("cls");
				SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_GREEN);
				cout<<"1p胜利";
				Sleep(2000);
				break;
			}
			if(((b2x==x1||b2y==y1)&&boom_time2==0)||((b1x==x1&&b1y==y1)&&boom_time==0)) {
				system("cls");
				SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_GREEN);
				cout<<"2p胜利";
				Sleep(2000);
				break;
			}
			if(boom_time==0) {
				b1x=14514;
				b1y=14514;
			}
			if(boom_time2==0) {
				b2x=14514;
				b2y=14514;
			}
			Sleep(200);
			if(boom_time>0) {
				boom_time--;
			}
			if(boom_time2>0) {
				boom_time2--;
			}
		}
		system("cls");
		cout<<"按o退出";
		while(!kbhit()) {

		}
		f=getch();
		system("cls");
		if(cn==1) {
			cn=2;
		} else if(cn==2) {
			cn=3;
		} else {
			cn=1;
		}
	}
	cout<<"游戏结束" ;
	return 0;
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值