跑酷_抢金币小游戏

发布一个抢金币小游戏~~

这是我朋友想编的

他和我讲了想法以后

被我写出来了[偷笑]

下面是代码:

#include<bits/stdc++.h>
#include<windows.h>
using namespace std;
int x=1,y=21,x3,y3;
int x1[10005],y2[10005];
int xy[10010][10010];
int coo=0;
int head(){
	cout<<"w向上,a向左,d向右,控制'0'"<<endl;
	cout<<"碰到'o'(金币),金币+1"<<endl;
	cout<<"碰到上方'=',结束游戏"<<endl; 
}
void GotoXY(int x,int y){
	HANDLE hout;
	COORD coord={x,y};
	hout=GetStdHandle(STD_OUTPUT_HANDLE);
	SetConsoleCursorPosition(hout,coord);
}
int za(){
	for(int i=1;i<=50;i++){
		x1[i]=rand()%98+3;
		y2[i]=rand()%20+1;
		if(x1[i]==x3&&y2[i]==y3){
			x1[i]++;
			y2[i]++;
		}
	}
	for(int i=1;i<=100;i++){
		GotoXY(x1[i],y2[i]);
		cout<<"=";
	}
}
int main(){
	char a;
	system("mode con cols=100 lines=25");
	head();
	Sleep(3000);
	system("CLS");
	x3=rand()%98+3;
	y3=rand()%20+1;
	GotoXY(1,21);
	cout<<0;
	int z=100;
	GotoXY(0,22);
	while(z--){
		cout<<"=";
	}
	GotoXY(x3,y3);
	cout<<"o";
	za();
	while(1){
		GotoXY(0,23);
		cin>>a;
		if(a=='a')x--;
		else if(a=='d')x++;
		else if(a=='w'){
			y-=6;
		}
		system("cls");
		GotoXY(0,22);
		z=100;
		while(z--){
			cout<<"=";
		}
		if(y>=22){
			y=21;
		}
		else if(y<21)y+=1;
		if(y<1)y=1;
		if(x==0)x++;
		else if(x==100)x--;
		if(x==x3&&y==y3){
			coo++;
			x3=rand()%98+3;
			y3=rand()%20+1;
			za();
		}
		for(int i=1;i<=50;i++){
			if(x==x1[i]&&y==y2[i]){
				cout<<"你死了!"<<endl; 
				system("pause");
			}
		}
		GotoXY(x,y);
		cout<<0;
		GotoXY(x3,y3);
		cout<<"o";
		GotoXY(0,50);
		cout<<"     金币"<<coo; 
		for(int i=1;i<=100;i++){
			GotoXY(x1[i],y2[i]);
			cout<<"=";
		}
	}
} 

如有bug

请多多指教!

 🙏


 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值