C++自制游戏 - 无尽之剑2.0

【置顶】无尽之剑3.0出了!更新:附魔,优化战斗。有需要关注私信我   

#include <iostream>
#include <cstdio>
#include<string>
#include<stdlib.h>
#include<map>
#include<algorithm>
#include<time.h>
#include<windows.h>
#include<conio.h>
#include<cmath>
using namespace std;

map<string,int>m;
char op;int dam=1,he=20,xp=0,fy=0;string pickaxe="none";
void ss(string s,int a)
{
    int len=s.length();
    for(int i=0;i<=len-1;i++)
    {
        cout << s[i];
        Sleep(40);
    }
    if(a==1)
    {
        cout << endl;
    }
}
void fight(int hp,int f)
{
    int h=hp;
    while(h>0)
    {
        system("cls");
        cout << "当前敌方血量:" << h << endl;
        int r;
        srand(time(0));
        Sleep(1000);
        if(rand()%3==0)
        {
            cout << "你打出了暴击伤害" << floor(dam * 1.5) << endl;
            h-=floor(dam * 1.5);
        }
        else
        {
            cout << "你打出了" << dam << "伤害" << endl;
            h-=dam;
        }
        cout << "敌方对你造成了" << floor((f / 100.0) * (100 - fy * 4))<< "伤害" << endl;
        he-=floor((f / 100.0) * (100 - fy * 4));
        cout << "你剩余" << he << "血量" << endl;
        if(he<=0)
        {
            while(1)
            {
                cout << "You died!" << endl;
                Sleep(500);
                system("cls");
            }
        }
        system("pause");
    }
    cout << "你打败了怪物" << endl;
    int o1;
    o1=(hp*2)+f;
    cout << "你获得了" << o1 << "经验" << endl;
    xp+=o1;
    system("pause");
}
int daguai()
{
    int mm;int nn;
    gongji:
    cout << "请输入你想要打的怪物的血量(本次输入需要按下回车)" << endl;
    
    cin >> mm;
    if(mm<=0)
    {
        cout << "输入无效" << endl;
        goto gongji;
    }
    gj:
    cout << &
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值