#define _CRT_SECURE_NO_WARNINGS 1
//没啥用之闲得无聊小游戏
#include <windows.h>
#include <iostream>
#include<time.h>
#include<stdio.h>
using namespace std;
int main()
{//如何让他按照我想的跳出循环呢,好怪啊md,有时候血量变负了还是需要一个步骤
int myblood = 100, enemyblood = 100, panding, panding2, myenery = 100, enemyenery = 100, qingkuang;
cout << "敌人血量: " << enemyblood << " " << "我的血量:" << myblood << "\n";
cout << "敌人蓝量:" << enemyenery << " " << "我的蓝量:" << myenery << "\n";
cout << "普A请按1,伤害技能请按2,回复技能请按3,吸收技能请按4,回复蓝量请按5(每个技能耗30点蓝)" << "\n";
while (enemyblood > 1 && myblood > 1)//跳出while的时候就需要判断谁赢谁输或者平局了
{//蓝量不够的时候无法放出技能
cin >> panding;//输入判定值进入循环体系
switch (panding) {
case 1:
{
enemyblood -= 10;
enemyenery -= 10;
myblood -= 20;
system("cls");//清屏
cout << "敌人血量: " << enemyblood << " " << "我的血量:" << myblood << "\n";
cout << "敌人蓝量:" << enemyenery << " " << "我的蓝量:" << myenery << "\n";
cout << "普A请按1,伤害技能请按2,回复技能请按3,吸收技能请按4,回复蓝量请按5" << "\n";
break;
}
case 2:
{
enemyblood -= 30;
myenery -= 30;
myblood -= 20;
enemyenery -= 10;
system("cls");//清屏
cout << "敌人血量: " << enemyblood << " " << "我的血量:" << myblood << "\n";
cout << "敌人蓝量:" << enemyenery << " " << "我的蓝量:" << myenery << "\n";
cout << "普A请按1,伤害技能请按2,回复技能请按3,吸收技能请按4,回复蓝量请按5" << "\n";
break;
}
case 3:
{
myblood += 30;
myenery -= 30;
myblood -= 20;
enemyenery -= 10;
system("cls");//清屏
cout << "敌人血量: " << enemyblood << " " << "我的血量:" << myblood << "\n";
cout << "敌人蓝量:" << enemyenery << " " << "我的蓝量:" << myenery << "\n";
cout << "普A请按1,伤害技能请按2,回复技能请按3,吸收技能请按4,回复蓝量请按5" << "\n";
break;
}
case 4:
{
myblood += 20;
myenery -= 30;
myblood -= 20;
enemyblood -= 20;
enemyenery -= 10;
system("cls");//清屏
cout << "敌人血量: " << enemyblood << " " << "我的血量:" << myblood << "\n";
cout << "敌人蓝量:" << enemyenery << " " << "我的蓝量:" << myenery << "\n";
cout << "普A请按1,伤害技能请按2,回复技能请按3,吸收技能请按4,回复蓝量请按5" << "\n";
break;
}
case 5:
{
myenery += 40;
myblood -= 20;
enemyenery -= 10;
system("cls");//清屏
cout << "敌人血量: " << enemyblood << " " << "我的血量:" << myblood << "\n";
cout << "敌人蓝量:" << enemyenery << " " << "我的蓝量:" << myenery << "\n";
cout << "普A请按1,伤害技能请按2,回复技能请按3,吸收技能请按4,回复蓝量请按5" << "\n";
break;
}
default:
cout << "输入无效,请按规范输入";
Sleep(500);//0.5秒的休息清屏时间
}
if (myenery <= 20)
{
cin >> panding2;
switch (panding2)
{
case 1:
{
enemyblood -= 10;
enemyenery -= 10;
myblood -= 20;
system("cls");//清屏
cout << "敌人血量: " << enemyblood << " " << "我的血量:" << myblood << "\n";
cout << "敌人蓝量:" << enemyenery << " " << "我的蓝量:" << myenery << "\n";
cout << "普A请按1,伤害技能请按2,回复技能请按3,吸收技能请按4,回复蓝量请按5" << "\n";
break;
}
case 2:
{
cout << "没蓝了,无效操作,请重新输入\n";//为什么第二次输入的值就不需要管蓝量多少都能触发?好怪啊
break;
}
case 3:
{
cout << "没蓝了,无效操作,请重新输入\n";
break;
}
case 4:
{
cout << "没蓝了,无效操作,请重新输入\n";
break;
}
case 5:
{
myenery += 40;
myblood -= 20;
enemyenery -= 10;
system("cls");//清屏
cout << "敌人血量: " << enemyblood << " " << "我的血量:" << myblood << "\n";
cout << "敌人蓝量:" << enemyenery << " " << "我的蓝量:" << myenery << "\n";
cout << "普A请按1,伤害技能请按2,回复技能请按3,吸收技能请按4,回复蓝量请按5" << "\n";
break;
}
default:
cout << "输入无效,请按规范输入";
Sleep(500);//0.5秒的休息清屏时间
}
}
}
if (enemyblood <= 0 && myblood > 0)
{
system("cls");
cout << "you win!!!!!";
}
if (myblood <= 0 && enemyblood > 0)
{
system("cls");
cout << "you lose~~~~";
}
if (myblood <= 0 && enemyblood <= 0)
{
system("cls");
cout << "without a winner ";
}
return 0;
}
已经能运行的小游戏二代
最新推荐文章于 2024-11-12 15:18:48 发布