c++の小游戏(原创俄罗斯转盘)

#include<iostream>
#include<ctime>
#include<cstdlib>
using namespace std;
int a,key1;
void rewt();//装弹程序
void start();//开场白
void ewnd();
int main()
{
	srand((unsigned)time(NULL));
	int d1, d2, d3, d4, d5, d6;
	d1 = 0; d2 = d1; d3 = d2; d4 = d3; d5 = d4; d6 = d5;
	int psin,k;
	k = 1;
	a = rand() % 6 + 1;
	rewt();
	if (key1 == 1)
	{
		d1 = 1;
	}
	else if (key1 == 2)
	{
		d2 = 1;
	}
	else if (key1 == 3)
	{
		d3 = 1;
	}
	else if (key1 == 4)
	{
		d4 = 1;
	}
	else if (key1 == 5)
	{
		d5 = 1;
	}
	else if (key1 == 6)
	{
		d6 = 1;
	}
	start();
	for (int turn = 1; turn >0;)
	{
		system("cls");
		if (k == 1)
		{
			cout << "你选择向自己开枪还是向我(电脑)开枪呢?" << endl << "0--向自己     1--向电脑" << endl << "你选择:";
			cin >> psin;
		}
		if (psin != 0 && psin != 1)//防止乱输
		{
			system("cls");
			cout << "很抱歉不知道因为什么原因,你输入了错误的选项,所以我便认为你是向自己开枪了" << endl;
			psin = 0;
			system("pause");
			system("cls");
		}
		if (turn == key1 && psin == 1&&k==1)//有子弹,打电脑
		{
			system("cls");
			cout << "3..." << endl;
			system("pause");
			cout << "2.." << endl;
			system("pause");
			cout << "1。" << endl;
			system("pause");
			system("cls");
			cout << "砰!";
			system("pause"); system("cls");
			cout << "随着刺耳的火药声响起,强烈的后坐力顺着你的右手袭来。";
			system("pause"); system("cls");
			cout << "子弹随着火舌从枪管里飞出,以500m/s的速度射向了你的对面。";
			system("pause"); system("cls"); system("color 03");//蓝字黑底
			cout << "你赢了...";
			turn = -99;
		}
		else if (turn == key1 && psin == 0&&k==1)//有子弹,打自己
		{
			system("cls");
			cout << "3..." << endl;
			system("pause");
			cout << "2.." << endl;
			system("pause");
			cout << "1。" << endl;
			system("pause");
			system("cls");
			cout << "砰!";
			system("pause"); system("cls");
			cout << "一瞬间,你感觉像是有颗小石子打在了你的头上……";
			system("pause"); system("cls");
			cout << "你的视野快速变得黑暗下来,双手交叉托住下巴正在偷笑的墨镜男人是你最后看见的东西。";
			system("pause"); system("cls");
			system("color 04");//红字黑底
			cout << "你死了。" << endl;
			system("pause");
			turn = -99;
		}
		else if (turn != key1 && psin == 1&&k==1)//无子弹,打电脑
		{
			system("cls");
			cout << "3..." << endl;
			system("pause");
			cout << "2.." << endl;
			system("pause");
			cout << "1。" << endl;
			system("pause");
			system("cls");
			cout << "叮.....";
			system("pause"); system("cls");
			cout << "随着清脆的扳机撞击声响起,什么都没有发生...." << endl;
			system("pause"); system("cls");
			cout << "“真幸运呐,看来是到我的回合了呢。”" << endl;
			system("pause"); system("cls");
			cout << "面前的墨镜男子轻笑了一下,从你手里接过了枪。" << endl;
			system("pause"); system("cls");
			k = 0;
		}
		else if (turn != key1 && psin == 0&&k==1)//无子弹,打自己
		{
			system("cls");
			cout << "3..." << endl;
			system("pause");
			cout << "2.." << endl;
			system("pause");
			cout << "1。" << endl;
			system("pause");
			system("cls");
			cout << "叮.....";
			system("pause"); system("cls");
			cout << "随着清脆的扳机撞击声响起,什么都没有发生...." << endl;
			system("pause"); system("cls");
			cout << "“真幸运呐,看来仍然还是你的回合呢。”" << endl;
			system("pause"); system("cls");
			cout << "冷汗顺着你的额头留下,看来你又能继续你的回合了,只是对面的墨镜男子看起来有些伤心。" << endl;
			system("pause"); system("cls");
		}
		else if (k == 0)//电脑回合
		{
			cout << "这局,是对方的回合。" << endl;
			system("pause"); 
			cout << "只见对方十分果断地就拿枪对准了你。";
			system("pause");
			cout << "然后..." << endl;
			system("pause"); system("cls");
			cout << "3..." << endl;
			system("pause");
			cout << "2.." << endl;
			system("pause");
			cout << "1。" << endl;
			system("pause");
			system("cls");
			if (turn == key1)
			{
				cout << "砰!" << endl;
				system("pause"); system("cls");
				cout << "你的视野快速变黑,手拿左轮并露出胜利微笑的墨镜男子是你最后看到的景象...";
				system("pause"); system("cls");
				system("pause"); system("cls");
				system("color 04");//红字黑底
				cout << "你死了。" << endl;
				turn = -99;
			}
			else
			{
				cout << "叮.....";
				system("pause"); system("cls");
				cout << "随着清脆的扳机撞击声响起,什么都没有发生...." << endl;
				system("pause"); system("cls");
				cout << "“哦呀,这都让你躲过去了,运气真好呢~”";
				system("pause"); system("cls");
				cout << "面前的墨镜男子轻笑一声,怂了怂肩,然后把枪递回给了你。";
				system("pause"); system("cls");
				cout << "接下来,又是你的回合。";
				k = 1;
			}
		}
		turn++;
	}
	ewnd();
}
void rewt()
{
	if (a == 1)
	{
		key1 = 1;
	}
	else if (a == 2)
	{
		key1 = 2;
	}
	else if (a == 3)
	{
		key1 = 3;
	}
	else if (a == 4)
	{
		key1 = 4;
	}
	else if (a == 5)
	{
		key1 = 5;
	}
	else if (a == 6)
	{
		key1 = 6;
	}
}
void start()
{
	cout << "welcome to this boring and disfunny's game!" << endl <<endl<< "now please choice your language." << endl<<endl;
	cout << "1---English       2---简体中文" << endl;
	int uuiii;
	cin >> uuiii;
	cout << "其实我是开玩笑的,根本没有英语,你输入什么都只是中文(手打狗头)" << endl;
	system("pause");
	system("cls");
	cout << "玩笑就开到这里,介绍一下游戏规则" << endl << endl << "这个游戏其实很简单,就是俄罗斯转盘,朋友。" << endl << endl;
	cout << "我现在往这把泵动式左轮手枪里上入了1颗子弹,但是没人知道我上在第几发(桀桀桀" << endl;
	system("pause");
	system("cls");
	cout << "现在从你开始,你可以选择对自己开枪,或是对我开枪。" << endl <<endl<< "如果你选择向自己开枪且侥幸,没错,是侥幸,侥幸活了下来的话,你就可以继续你的回合" << endl;
	cout<<endl << "如果你选择朝我开枪且使我活了下来的话" << endl;
	system("pause");
	system("cls");
	cout << "那么朋友,接下来就是我的回合了。" << endl;
	system("pause");
}
void ewnd()
{
	system("color 02");
	cout << "非常感谢宁的游玩!这个小小小小小游戏是我花两个小时在图书馆里编辑出来的。有意见和看法都可以联系我告诉我哟~";
	system("pause"); system("cls");
	
}

还在持续改进中……

本人是准大一学生,自学c++语言在闲暇便写了这个小游戏,希望大家能多多提出意见,蟹蟹!

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值