c++小游戏,简单易懂,萌新也能写出来

投篮小游戏

 

#include<bits/stdc++.h>
#include<windows.h>
using namespace std;
int rs,drx,cnt,gz,jf;
void start(){
	cout<<" 投篮小游戏1.1.0(作者:罗辑之趣) "<<endl;
	cout<<"       O                      设置 "<<endl;
	cout<<"|_                                 "<<endl;
	cout<<"|_|                                "<<endl;
	cout<<"|                            |o|   "<<endl;
	cout<<"|                             |    "<<endl;
	cout<<"|                            /|    "<<endl;
	cout<<"                                   "<<endl;
	cout<<"                                   "<<endl;
	cout<<"输入start开始游戏...               "<<endl;
	cout<<"输入sz查看已有多少积分...          "<<endl; 
	string a;
	cin>>a;
	if(a=="start"){
		system("cls");
		cout<<"开 始 游 戏 ! ! !"<<endl;
		Sleep(2500);
		system("cls");
	}
	if(a=="sz"){
		system("cls");
		cout<<"您现在有"<<jf<<"个积分"<<endl;
		Sleep(2500);
		system("cls");
		start();
	}
}
void guize(){
	cout<<"          介绍游戏规则"<<endl;
	cout<<"共有11个格子"<<endl;
	cout<<"玩家根据运气投篮(其实只是输入“投篮”)"<<endl;
	cout<<"每次投篮进球概率为75%(是因为作者测试了n次50%都过不了关,觉得自己运气好的可以调一下)"<<endl;
	cout<<"每成功通关一次可获得10积分(其实没什么用)"<<endl;
	cout<<"注:作者的代码很弱,有建议可以在评论区提出来"<<endl;
	Sleep(5000);
}
void kaishi(){
	cout<<"选择游戏人数:单人/双人(尚未开发)(1)"<<endl;
	int a,x,y;
	char b,c;
	cin>>a;
	rs=1;
	if(rs==1){
		cout<<"你是否在x次未投进后后退1格?(y/n)"<<endl;
		cin>>b;
		if(b=='y'){
			cout<<"x为几?(1-10)"<<endl;
			cin>>x;
			if(x<1||x>10){
				cout<<"输入错误!"<<endl;
				drx=999999999;
				return;
			}
			else{
				drx=x;
				cout<<"游戏正式开始"<<endl;
			}
		}
		else{
			drx=999999999;
			cout<<"游戏正式开始"<<endl;
		}
	}
	Sleep(2500);
	system("cls");
}
void dh_jq(){
	cout<<"                            "<<endl;
	cout<<"                           |"<<endl;
	cout<<"  /O                      _|"<<endl;
	cout<<"  o/                     |_|"<<endl;
	cout<<"  |                        |"<<endl;
	cout<<" /|                        |"<<endl;
	Sleep(1000);
	system("cls");
	cout<<"                   O        "<<endl;
	cout<<"                           |"<<endl;
	cout<<"   /o/                    _|"<<endl;
	cout<<"   /                     |_|"<<endl;
	cout<<"  /|                       |"<<endl;
	cout<<"                           |"<<endl;
	Sleep(1000);
	system("cls");
	cout<<"                           "<<endl;
	cout<<"                          |"<<endl;
	cout<<"                         O|"<<endl;
	cout<<"  /o/                   |_|"<<endl;
	cout<<"   |                      |"<<endl;
	cout<<"  /|                      |"<<endl;
	Sleep(1000);
	system("cls");
	cout<<" g                                          hf          gjfhkegkhdbvsdhajkvb"<<endl;
	cout<<"         dsf   kdg                          xd    tp                    bds"<<endl;
	cout<<"         dff   kib                          yd    oy                  dsd"<<endl;
	cout<<" dfss  dgdrhbgdfbgrdt       sdsdgdsj        wh                      kds"<<endl;
	cout<<"   s   dbsfjkbhdbkjbh          d       zxyisalarges               bds"<<endl;
	cout<<"  d      bgf   gui             f       g    jy    j             dsk"<<endl;
	cout<<" g     bfhdkgbhjsbkhs       ggffsdih    g   hd   o              dfs"<<endl;
	cout<<" u     bvhfukvbhdkbvj          f         g  in  p               vig"<<endl;
	cout<<"  f      hdf   huk             r  i    g    oi   q              bvd"<<endl;
	cout<<"   g     bgh   iuf             hf      a    ww   j           op vdg"<<endl;
	cout<<"    i  egrd                  jb          nu sb                ue d"<<endl;
	cout<<"            bgrdnbnfb       f               bf                 qtd"<<endl;
	Sleep(2500);
	system("cls");
}
void dh_wjq(){
	cout<<"                            "<<endl;
	cout<<"                           |"<<endl;
	cout<<"  /O                      _|"<<endl;
	cout<<"  o/                     |_|"<<endl;
	cout<<"  |                        |"<<endl;
	cout<<" /|                        |"<<endl;
	Sleep(1000);
	system("cls");
	cout<<"                            "<<endl;
	cout<<"                 O         |"<<endl;
	cout<<"   /o/                    _|"<<endl;
	cout<<"   /                     |_|"<<endl;
	cout<<"  /|                       |"<<endl;
	cout<<"                           |"<<endl;
	Sleep(1000);
	system("cls");
	cout<<"                           "<<endl;
	cout<<"                          |"<<endl;
	cout<<"                         _|"<<endl;
	cout<<"  /o/                  O|_|"<<endl;
	cout<<"   |                      |"<<endl;
	cout<<"  /|                      |"<<endl;
	Sleep(1000);
	system("cls");
	cout<<"           dh                 g                                          hf"<<endl;
	cout<<"           jk                         dsf   kdg                          xd    tp"<<endl;
	cout<<"      dsbdsggfnutj                    dff   kib                          yd    oy"<<endl;
	cout<<"           la                 dfss  dgdrhbgdfbgrdt       sdsdgdsj        wh"<<endl;
	cout<<" dbshkuvbhfkvbskvkskvv          s   dbsfjkbhdbkjbh          d       zxyisalarges"<<endl;
	cout<<"         v yf u                d      bgf   gui             f       g    jy    j"<<endl;
	cout<<"        u  hh  x              g     bfhdkgbhjsbkhs       ggffsdih    g   hd   o"<<endl;
	cout<<"       a   gs   o             u     bvhfukvbhdkbvj          f         g  in  p"<<endl;
	cout<<"      a    xa    z             f      hdf   huk             r  i    g    oi   q"<<endl;
	cout<<"    df     hm     ph            g     bgh   iuf             hf      a    ww   j"<<endl;
	cout<<"           ih                    i  egrd                  jb          nu sb"<<endl;
	cout<<"           xc                            bgrdnbnfb       f               bf"<<endl;
	Sleep(2500);
	system("cls");
}
void jm_1(){
	cout<<"  |    |    |    ---   你  "<<endl;
	cout<<"                      _____"<<endl;
	cout<<"                     |    |"<<endl;
	cout<<" -                   |    |"<<endl;
	cout<<"                     |____|"<<endl;
	cout<<"                           "<<endl;
	cout<<"  |    |    |    ---    |  "<<endl;
}
void jm_2(){
	cout<<"  |    |    |    你    |   "<<endl;
	cout<<"                      _____"<<endl;
	cout<<"                     |    |"<<endl;
	cout<<" -                   |    |"<<endl;
	cout<<"                     |____|"<<endl;
	cout<<"                           "<<endl;
	cout<<"  |    |    |    ---    |  "<<endl;
}
void jm_3(){
	cout<<"  |    |    你    ---    | "<<endl;
	cout<<"                      _____"<<endl;
	cout<<"                     |    |"<<endl;
	cout<<" -                   |    |"<<endl;
	cout<<"                     |____|"<<endl;
	cout<<"                           "<<endl;
	cout<<"  |    |    |    ---    |  "<<endl;
}
void jm_4(){
	cout<<"  |    你   |     ---    | "<<endl;
	cout<<"                      _____"<<endl;
	cout<<"                     |    |"<<endl;
	cout<<" -                   |    |"<<endl;
	cout<<"                     |____|"<<endl;
	cout<<"                           "<<endl;
	cout<<"  |    |    |    ---    |  "<<endl;
}
void jm_5(){
	cout<<"  你    |   |     ---    | "<<endl;
	cout<<"                      _____"<<endl;
	cout<<"                     |    |"<<endl;
	cout<<" -                   |    |"<<endl;
	cout<<"                     |____|"<<endl;
	cout<<"                           "<<endl;
	cout<<"  |    |    |    ---    |  "<<endl;
}
void jm_6(){
	cout<<"  |    |    |   ---    | "<<endl;
	cout<<"                      _____"<<endl;
	cout<<"                     |    |"<<endl;
	cout<<" 你                  |    |"<<endl;
	cout<<"                     |____|"<<endl;
	cout<<"                           "<<endl;
	cout<<"  |    |    |    ---    |  "<<endl;
}
void jm_7(){
	cout<<"  |    |    |    ---    |  "<<endl;
	cout<<"                      _____"<<endl;
	cout<<"                     |    |"<<endl;
	cout<<" -                   |    |"<<endl;
	cout<<"                     |____|"<<endl;
	cout<<"                           "<<endl;
	cout<<"  你    |    |    ---    | "<<endl;
}
void jm_8(){
	cout<<"  |    |    |    ---    |  "<<endl;
	cout<<"                      _____"<<endl;
	cout<<"                     |    |"<<endl;
	cout<<" -                   |    |"<<endl;
	cout<<"                     |____|"<<endl;
	cout<<"                           "<<endl;
	cout<<"  |    你    |    ---    | "<<endl;
}
void jm_9(){
	cout<<"  |    |    |    ---    |  "<<endl;
	cout<<"                      _____"<<endl;
	cout<<"                     |    |"<<endl;
	cout<<" -                   |    |"<<endl;
	cout<<"                     |____|"<<endl;
	cout<<"                           "<<endl;
	cout<<"  |    |    你    ---    | "<<endl;
}
void jm_10(){
	cout<<"  |    |    |    ---    |  "<<endl;
	cout<<"                      _____"<<endl;
	cout<<"                     |    |"<<endl;
	cout<<" -                   |    |"<<endl;
	cout<<"                     |____|"<<endl;
	cout<<"                           "<<endl;
	cout<<"  |    |    |    你    |   "<<endl;
}
void jm_11(){
	cout<<"  |    |    |    ---    |  "<<endl;
	cout<<"                      _____"<<endl;
	cout<<"                     |    |"<<endl;
	cout<<" -                   |    |"<<endl;
	cout<<"                     |____|"<<endl;
	cout<<"                           "<<endl;
	cout<<"  |    |    |    ---    你 "<<endl;
}
void sr(){
	cout<<"按任意键投篮..."<<endl;
	system("pause");
}
void tg(){
	cout<<"成功通关!!!积分+10"<<endl;
	jf+=10; 
}
void wan_dr(){
	kaishi();
	guize();
	part1:{
		system("cls");
		jm_1();
		Sleep(1000);
		gz=1;
		sr();
		srand(time(0));
		int a=rand()%4;
		if(a==0||a==1||a==2){
			system("cls");
			dh_jq();
			cnt=0;
			gz++;
			system("cls");
			jm_2();
		}
		else{
			system("cls");
			dh_wjq();
			cnt++;
			if(cnt==drx)
				if(gz>1){
					gz--;
					cnt=0;
				}
		}
	}
	if(gz==1)
		goto part1;
	part2:{
		system("cls");
		jm_2();
		Sleep(1000);
		gz=2;
		sr();
		srand(time(0));
		int a=rand()%4;
		if(a==0||a==1||a==2){
			system("cls");
			dh_jq();
			cnt=0;
			gz++;
			system("cls");
			jm_3();
		}
		else{
			system("cls");
			dh_wjq();
			cnt++;
			if(cnt==drx)
				if(gz>1){
					gz--;
					cnt=0;
				}
		}
	}
	if(gz==1)
		goto part1;
	if(gz==2)
		goto part2;
	part3:{
		system("cls");
		jm_3();
		Sleep(1000);
		gz=3;
		sr();
		srand(time(0));
		int a=rand()%4;
		if(a==0||a==1||a==2){
			system("cls");
			dh_jq();
			cnt=0;
			gz++;
			system("cls");
			jm_4();
		}
		else{
			system("cls");
			dh_wjq();
			cnt++;
			if(cnt==drx)
				if(gz>1){
					gz--;
					cnt=0;
				}
		}
	}
	if(gz==1)
		goto part1;
	if(gz==2)
		goto part2;
	if(gz==3)
		goto part3;
	part4:{
		system("cls");
		jm_4();
		Sleep(1000);
		gz=4;
		sr();
		srand(time(0));
		int a=rand()%4;
		if(a==0||a==1||a==2){
			system("cls");
			dh_jq();
			cnt=0;
			gz++;
			system("cls");
			jm_5();
		}
		else{
			system("cls");
			dh_wjq();
			cnt++;
			if(cnt==drx)
				if(gz>1){
					gz--;
					cnt=0;
				}
		}
	}
	if(gz==1)
		goto part1;
	if(gz==2)
		goto part2;
	if(gz==3)
		goto part3;
	if(gz==4)
		goto part4;
	part5:{
		system("cls");
		jm_5();
		Sleep(1000);
		gz=5;
		sr();
		srand(time(0));
		int a=rand()%4;
		if(a==0||a==1||a==2){
			system("cls");
			dh_jq();
			cnt=0;
			gz++;
			system("cls");
			jm_6();
		}
		else{
			system("cls");
			dh_wjq();
			cnt++;
			if(cnt==drx)
				if(gz>1){
					gz--;
					cnt=0;
				}
		}
	}
	if(gz==1)
		goto part1;
	if(gz==2)
		goto part2;
	if(gz==3)
		goto part3;
	if(gz==4)
		goto part4;
	if(gz==5)
		goto part5;
	part6:{
		system("cls");
		jm_6();
		Sleep(1000);
		gz=6;
		sr();
		srand(time(0));
		int a=rand()%4;
		if(a==0||a==1||a==2){
			system("cls");
			dh_jq();
			cnt=0;
			gz++;
			system("cls");
			jm_7();
		}
		else{
			system("cls");
			dh_wjq();
			cnt++;
			if(cnt==drx)
				if(gz>1){
					gz--;
					cnt=0;
				}
		}
	}
	if(gz==1)
		goto part1;
	if(gz==2)
		goto part2;
	if(gz==3)
		goto part3;
	if(gz==4)
		goto part4;
	if(gz==5)
		goto part5;
	if(gz==6)
		goto part6;
	part7:{
		system("cls");
		jm_7();
		Sleep(1000);
		gz=7;
		sr();
		srand(time(0));
		int a=rand()%4;
		if(a==0||a==1||a==2){
			system("cls");
			dh_jq();
			cnt=0;
			gz++;
			system("cls");
			jm_8();
		}
		else{
			system("cls");
			dh_wjq();
			cnt++;
			if(cnt==drx)
				if(gz>1){
					gz--;
					cnt=0;
				}
		}
	}
	if(gz==1)
		goto part1;
	if(gz==2)
		goto part2;
	if(gz==3)
		goto part3;
	if(gz==4)
		goto part4;
	if(gz==5)
		goto part5;
	if(gz==6)
		goto part6;
	if(gz==7)
		goto part7;
	part8:{
		system("cls");
		jm_8();
		Sleep(1000);
		gz=8;
		sr();
		srand(time(0));
		int a=rand()%4;
		if(a==0||a==1||a==2){
			system("cls");
			dh_jq();
			cnt=0;
			gz++;
			system("cls");
			jm_9();
		}
		else{
			system("cls");
			dh_wjq();
			cnt++;
			if(cnt==drx)
				if(gz>1){
					gz--;
					cnt=0;
				}
		}
	}
	if(gz==1)
		goto part1;
	if(gz==2)
		goto part2;
	if(gz==3)
		goto part3;
	if(gz==4)
		goto part4;
	if(gz==5)
		goto part5;
	if(gz==6)
		goto part6;
	if(gz==7)
		goto part7;
	if(gz==8)
		goto part8;
	part9:{
		system("cls");
		jm_9();
		Sleep(1000);
		gz=9;
		sr();
		srand(time(0));
		int a=rand()%4;
		if(a==0||a==1||a==2){
			system("cls");
			dh_jq();
			cnt=0;
			gz++;
			system("cls");
			jm_10();
		}
		else{
			system("cls");
			dh_wjq();
			cnt++;
			if(cnt==drx)
				if(gz>1){
					gz--;
					cnt=0;
				}
		}
	}
	if(gz==1)
		goto part1;
	if(gz==2)
		goto part2;
	if(gz==3)
		goto part3;
	if(gz==4)
		goto part4;
	if(gz==5)
		goto part5;
	if(gz==6)
		goto part6;
	if(gz==7)
		goto part7;
	if(gz==8)
		goto part8;
	if(gz==9)
		goto part9;
	part10:{
		system("cls");
		jm_10();
		Sleep(1000);
		gz=10;
		sr();
		srand(time(0));
		int a=rand()%4;
		if(a==0||a==1||a==2){
			system("cls");
			dh_jq();
			cnt=0;
			gz++;
			system("cls");
			jm_11();
		}
		else{
			system("cls");
			dh_wjq();
			cnt++;
			if(cnt==drx)
				if(gz>1){
					gz--;
					cnt=0;
				}
		}
	}
	if(gz==1)
		goto part1;
	if(gz==2)
		goto part2;
	if(gz==3)
		goto part3;
	if(gz==4)
		goto part4;
	if(gz==5)
		goto part5;
	if(gz==6)
		goto part6;
	if(gz==7)
		goto part7;
	if(gz==8)
		goto part8;
	if(gz==9)
		goto part9;
	if(gz==10)
		goto part10;
	part11:{
		system("cls");
		jm_11();
		Sleep(1000);
		gz=11;
		sr();
		srand(time(0));
		int a=rand()%4;
		if(a==0||a==1||a==2){
			system("cls");
			dh_jq();
			cnt=0;
			gz++;
			system("cls");
			tg();
		}
		else{
			system("cls");
			dh_wjq();
			cnt++;
			if(cnt==drx)
				if(gz>1){
					gz--;
					cnt=0;
				}
		}
	}
	if(gz==1)
		goto part1;
	if(gz==2)
		goto part2;
	if(gz==3)
		goto part3;
	if(gz==4)
		goto part4;
	if(gz==5)
		goto part5;
	if(gz==6)
		goto part6;
	if(gz==7)
		goto part7;
	if(gz==8)
		goto part8;
	if(gz==9)
		goto part9;
	if(gz==10)
		goto part10;
	if(gz==11)
		goto part11;
	start();
}
int main(){
	start();
	wan_dr();
	return 0;
}

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值