用C++写一个生存游戏

#include<bits/stdc++.h>
#include<windows.h>
#include<cstdio>
#include <time.h>
#include<iostream>
#include<conio.h>
#define HD 29
using namespace std;
int hp=100,bsd=100,water=100,nl=100;
bool han=0;int fire=0;
//                      1      2     3      4        5       6        7        8      9     10     11     12     13         14        15    16     17    18    19       20       21     22      23      24      25    26      27     28     29 
string name[100]={"0","木条","木板","石头","碎石","平滑石","捕鱼笼","捕兽夹","苹果","浆果","皮毛","生肉","熟肉","木桶","装有水的木桶","船","火把","藤蔓","弓","石剑","地图碎片","地图","磁石","指南针","石斧","生鱼","熟鱼","金币","铁锭","金锭"};
int num[100];
///
int animal;//是否探索到野兽小径 1探索到了 0没有探索到

int berry;//是否探索到浆果地 1探索到了 0没有探索到
int berry_time=10;
int YNberry;//berry_time:浆果的状态berry_time>=10时浆果成熟   YNberry:浆果是否种植1种植了0没种植 
 
int brook;//是否探索到小溪   1探索到了 0没探索到
int fcageplace;//捕鱼笼数量(已放置)
int acageplace;//捕兽夹数量(已放置)
int YNcatchfish;//是否捕到鱼(大于等于10时,每个捕鱼笼有几率获得3~6条鱼)
int YNcatchanimal;//是否捕到野兽(大于等于20时,每个捕鱼笼有几率获得3~5块肉)
///
int hand[100];
int YNenergy=1;
int fmenu=1;
char choose;

void print(char a[]);
void juqin();
void login();
void home();
void bag();
void table();
void gotable();
void goberry();
void gobrook();
void goanimal();
void main_menu();
void empty();
//
int main(){
	for(int i=1;i<=HD;i++){
	    hand[i]=100;
	}
    han=1;
    srand(time(NULL));
    system("color 0E");
    system("MODE CON COLS=30 LINES=10");
    srand(time(NULL));
    system("title 秘境");
    cout<<"剧情?输入1:\n";
    int t;
    cin>>t;
    if(t==1)juqin();
    system("cls");
    print("    秘境");
    print("HUAWEI传奇出品");
    system("pause");
    system("cls");
    print("HUAWEI出品");
    system("pause");
    login();
    system("MODE CON COLS=60 LINES=40");
    home();
    return 0;
}
void empty(){
    hp=bsd=water=nl=100;
    memset(num,0,sizeof(0));
    memset(hand,0,sizeof(0));
    han=fire=animal=berry=YNberry=brook=fcageplace=acageplace=YNcatchfish=YNcatchanimal=0;
    berry_time=10;
    for(int i=1;i<=HD;i++) num[i]=hand[i]=0;
}
void print(char a[]){
    for(int i=0;i<strlen(a);i++){
        Sleep(10);
        cout<<a[i];
    }
    cout<<endl;
}
void main_menu(){
    system("MODE CON COLS=30 LINES=15");
    while(1){
        system("cls");
        printf("            主菜单\n");
        if(fmenu==1){ 
            printf("         ------------\n");
            printf("         + 继续游戏 +\n");
            printf("         ------------");
        }else if(fmenu!=1){
            printf("\n           继续游戏\n");
        }
        if(fmenu==2){
            printf("         ------------\n");
            printf("         + 重开游戏 +\n");
            printf("         ------------\n");
        }else if(fmenu!=2){
            printf("\n           重开游戏\n");
        }
        choose=getch();
        if(choose=='w'){
            if(fmenu!=1) fmenu--; 
        }
        else if(choose=='s'){
            if(fmenu!=2) fmenu++;
        }else if(choose==' '){
            if(fmenu==1){
                return;
            }
            if(fmenu==2){
                //是 6 不是 7 
                if(MessageBox(NULL,"这将丢失你目前的存档,确定要重开游戏吗?","提示",MB_YESNO)==6){
                    empty();
                    return;
                }
            }
        }
    }
}
void home(){
    int time=0;
    while(1){
        YNenergy=0; 
        time++;
        system("cls");
        cout<<"现在是";
        if((time/12)%2==0)cout<<"白天"<<endl;
        else cout<<"黑夜"<<endl;
        cout<<"这是你被困在这里的第"<<time/24+1<<"天......"<<endl;
        cout<<"血量:"<<hp<<" "<<"饱食度:"<<bsd<<" "<<"口渴度:"<<water<<" "<<"耐力:"<<nl<<endl;
        if(berry_time>=10 && berry==1){
            cout<<"浆果已成熟!"<<endl;
        }
        if(YNcatchfish>=10 && brook==1){
            cout<<"捕鱼笼已捕到鱼!"<<endl;
        }
        if(YNcatchanimal>=20 && animal==1){
            cout<<"捕兽夹已捕到猎物!"<<endl;
        }
        if(fire==2)cout<<"火堆熊熊燃烧"<<endl;
        if(fire==1)cout<<"火堆燃烧着"<<endl;
        if(bsd<=50)cout<<"你感到很饿"<<endl;
        if(water<=50)cout<<"你感到很渴"<<endl;
        if(nl<=50)cout<&
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值