• 个人简介

    is some thing only apple can do 完整整合版:《猫国:雪夜里的归处》全文小说 + 可直接编译运行C++游戏源码

    猫国:雪夜里的归处

    序章 老院的铜钥匙

    阿柚是在整理奶奶遗物时找到那把钥匙的。 老樟木箱子的最底层,裹着褪色的碎花手帕,躺着一枚铜制的猫形钥匙,钥匙柄磨得发亮,背面刻着两个小字:猫国。旁边压着张旧照片,年轻的奶奶蹲在巷口,怀里抱着只左耳缺了一小块的白猫,脚边卧着圆滚滚的橘猫,阳光落在她们身上,软得像一团棉花。

    奶奶走后的第三个月,老院的后窗总在半夜发出轻响。这天深夜,阿柚攥着钥匙走到后院,看见那扇封了十几年的木门正泛着暖黄的光。她鬼使神差地把钥匙插进去,“咔嗒”一声,门开了。 风裹着淡淡的桂花香涌出来,门后不是熟悉的巷弄,是一座铺着青石板的小城,城门上挂着木牌,写着:猫国。

    第一章 新任领主

    城门边守着只穿短褂的灰斑猫,看见她立刻站直身子:“领主大人,您终于来了。” 阿柚愣住了。灰斑猫引着她往主城走,沿路的屋顶上、墙根下,都蹲着大大小小的猫咪,好奇地探着头看她。主城广场的石台上,摆着一枚雕着猫爪的令牌,令牌侧面刻着一个歪歪扭扭的“柚”字。 “老领主说,等她走了,就把猫国交给你。”灰斑猫的声音放轻,“她等了你好久。” 阿柚握着令牌,指尖发烫。她以为这是一场离奇的梦,直到居民区的巷口,走过来一只白猫。 白猫左耳缺了小小的一块,步伐很慢,走到她脚边,用脑袋轻轻蹭了蹭她的裤腿。 阿柚蹲下来,声音忽然发颤:“……白絮?” 这是她给照片里那只小猫取的名字。她小时候总指着照片说,等长大了,要和奶奶一起养它。

    第二章 居民区的旧闻

    居民区住着最老的一批猫民。巷口晒太阳的棕耳老猫,眯着眼睛看了阿柚半天,慢悠悠开口:“像,真像。” 它说,很多年前,猫国还只是一片荒地。有个人类女人常带着猫粮过来,给流浪猫搭窝,治伤,一点点建起了房子,铺了路。猫咪们都喊她老领主。 “老领主总说,她有个小孙女,最喜欢猫,就是胆子小,怕生。”棕耳猫舔了舔爪子,“她说等小孙女长大了,就带她来猫国当领主。” 阿柚坐在石阶上,手里攥着白絮的爪子。她想起奶奶生前总蹲在小区楼下喂猫,口袋里永远装着小鱼干,下雨天会给流浪猫搭纸箱窝。那时候她还总笑奶奶,说奶奶都快成猫司令了。 原来奶奶真的建了一个国。 那天她在居民区走了一下午。每只猫的名字,奶奶都跟她讲过:花尾是从下水道救出来的,银霜是冬天在车站捡到的,短腿橘是跟着奶奶走了三公里路,赖在家里不肯走的。 每一只猫,都是奶奶藏在岁月里的温柔。

    第三章 幽暗森林的木屋

    森林是猫国的物资库。阿柚跟着猫咪们去捡木柴,越往深处走,桂花香越浓。 森林最深处,藏着一间小木屋。 木门没锁,推开门的瞬间,阿柚的眼泪一下子掉了下来。 木屋里摆着奶奶的绒线筐,里面还有没织完的小围巾——是奶奶当年说要给她织的,后来奶奶眼睛花了,织了一半就放下了。墙角堆着她小时候的涂鸦,画着歪歪扭扭的猫咪和奶奶,旁边用蜡笔写着:我和奶奶的猫王国。 窗台上放着一个玻璃罐,罐子里装满了晒干的桂花。是奶奶院子里那棵老桂树的花,每年秋天,奶奶都会晒桂花,给她泡桂花茶。 白絮跳上窗台,用爪子扒拉玻璃罐。阿柚忽然想起,十年前的冬天,就是在这片森林对应的巷口,白絮为了护着刚上小学的她,被野狗咬破了耳朵。奶奶抱着白絮跑了三站路去宠物医院,回来跟她说,小白猫是小英雄。 原来它一直记得。 原来她们都记得。

    第四章 集市的老猫商

    集市在猫国的东街,最里面的摊位,坐着只胡子花白的老猫。 看见阿柚过来,老猫商愣了好久,手忙脚乱地把摊子上最好的猫粮往她面前推:“拿去吧拿去吧,不要钱。老领主以前总来我这儿买猫粮,每次都多给两个铜板,说让我多吃点。” 它偷偷塞给阿柚一块小鱼干,鱼干的味道和奶奶做的一模一样。 “老领主最后一次来集市,是去年秋天。”老猫商的声音低下去,“她买了好多猫粮,说要囤着,等她的小孙女来。她还说,小孙女爱吃南瓜蛋糕,等下雪了,要给她做。” 阿柚攥着鱼干,站在集市的石板路上,哭得像个孩子。 她总以为奶奶走得匆忙,没来得及留下什么。可奶奶早就把所有的温柔,都悄悄搬进了这座猫国里。

    第五章 神庙的壁画

    猫国的山顶有座神庙,据说对着壁画许愿,愿望会传到天上。 阿柚爬上山的时候,夕阳正落在神庙的壁画上。 壁画很长,从一个年轻女人抱着橘猫走进荒地开始画:她给猫咪搭窝,给受伤的猫上药,一点点建起房子,铺起街道;后来她头发白了,身边多了个扎羊角辫的小女孩,小女孩蹲在地上,给猫咪喂小鱼干;最后一幅画,是老奶奶站在城门口,望着远方,身边围着所有猫咪,画的角落写着一行小字: 愿我的小柚,永远有猫相伴,永远有归处。 壁画的最顶端,蹲着一只圆滚滚的橘猫,脖子上挂着小铃铛。 是橘子。奶奶养了十五年的橘猫,在奶奶走的前一年,先一步去了喵星。 原来它早就来猫国了,在这里等着奶奶,也等着她。 那天阿柚在神庙里坐了很久。风穿过廊柱,带着轻轻的声响,像奶奶小时候哄她睡觉的歌谣。

    终章 第一场雪

    猫国的第一场雪,落得很轻。 阿柚推开领主府的门,看见所有猫咪都聚在广场上。广场中间,摆着一个南瓜蛋糕,蛋糕上插着蜡烛,旁边堆着大大小小的礼物:猫咪们叼来的羽毛、晒干的花、光滑的小石子。 老猫商摸着胡子笑:“老领主临走前交代的,说你今天生日,要给你做南瓜蛋糕。她提前教了我们好久。” 白絮叼着一个小布包走过来,布包里是奶奶的老花镜,还有一张纸条,是奶奶的字迹: “小柚,奶奶在猫国给你留了好多猫咪,它们会替奶奶陪着你。不要怕,不管什么时候,这里永远是你的家。” 雪落在猫咪们的毛上,软乎乎的。阿柚吹灭蜡烛的时候,仿佛看见奶奶站在城门口,笑着朝她挥了挥手,转身走进了漫天飞雪里。 她终于明白,离别从来不是终点。 那些爱过的人,会化作风,化作花,化作满城的猫咪,化作每一个雪夜里的温暖,永远陪在你身边。 猫国永远有光,永远有归处。 《猫国:雪夜里的归处》观赏说明书

    一、世界观设定

    1. 猫国本质:由人类的善意与执念凝聚而成的异次元国度,所有被真心爱过的猫咪,都会在猫国拥有安稳的归宿;真心爱着猫咪的人,会在特定时刻收到通往猫国的邀请。

    2. 区域对应:猫国的每一处场景,都对应着奶奶现实里的生活痕迹——居民区是奶奶住了一辈子的老巷,森林是巷口的小公园,集市是奶奶常去的菜市场,神庙是奶奶常去祈福的老庵堂,矿山是奶奶年轻时做工的石料厂。

    3. 时间规则:猫国的时间流速和人间不同,人间一夜,猫国可以度过完整的白天;每年奶奶的忌日和阿柚的生日,猫国一定会下雪。

    二、代码

    #include<iostream>
    #include<cstdlib>
    #include<ctime>
    #include<fstream>
    #include<string>
    #include<limits>      // 用于输入验证
    #include<windows.h>   // 保留用于 Sleep(),如果要跨平台可用 chrono 替代
    using namespace std;
    
    // ===================== 常量定义 =====================
    const int MAX_CATS = 14;           // 最大猫咪数量
    const int ENDING_DAY = 15;         // 触发结局所需天数
    const int ENDING_FAME = 200;       // 触发结局所需声望
    const int ENDING_CATS = 8;         // 触发结局所需猫咪数量
    const int RECRUIT_THRESHOLD = 55;  // 招募基础阈值
    const int MAX_PLAYER_HP = 100;
    const int MAX_EGGS = 9;
    
    // ===================== 游戏数据封装 =====================
    struct GameData {
        // 玩家信息
        string playerName;
        int day, hour;
        int weather; // 1晴天 2阴天 3小雨 4雪天
        
        // 资源
        int fame, gold, food, stone, wood;
        
        // 猫咪
        int catNum;
        bool catUnlock[MAX_CATS + 1];  // 索引1-14使用
        int catLevel[MAX_CATS + 1];
        
        // 道具
        int medicine, trap;
        int blessDay;
        int playerHp, playerMaxHp, playerAtk;
        
        // 剧情标记
        bool plot_start, plot_baiXu, plot_oldResident;
        bool plot_woodHouse, plot_marketOld, plot_templeMural;
        bool plot_ending;
        int eggCount;
        
        // 构造函数
        GameData() {
            Init();
        }
        
        void Init() {
            day = 1; hour = 8;
            fame = 10; gold = 120; food = 35;
            stone = 15; wood = 20; catNum = 0;
            medicine = 3; trap = 2; blessDay = 0;
            playerHp = 100; playerMaxHp = 100; playerAtk = 18;
            weather = 1;
            
            for(int i = 1; i <= MAX_CATS; i++) {
                catUnlock[i] = false;
                catLevel[i] = 1;
            }
            
            plot_start = false;
            plot_baiXu = false;
            plot_oldResident = false;
            plot_woodHouse = false;
            plot_marketOld = false;
            plot_templeMural = false;
            plot_ending = false;
            eggCount = 0;
        }
    };
    
    // ===================== 全局游戏数据 =====================
    GameData game;
    
    // 猫咪名称数组
    const string catName[MAX_CATS + 1] = {
        "", "白絮", "灰斑", "橘胖", "暗影", "奶团", 
        "虎纹", "雪毛", "棕耳", "花尾", "短尾", 
        "银霜", "焦糖", "月夜", "云纹"
    };
    
    // ===================== 前置声明 =====================
    void InitGame();
    void TimePass();
    void WeatherRefresh();
    void MainCity();
    void ResidentialArea();
    void Forest();
    void Market();
    void MineArea();
    void Temple();
    void WildBattle();
    void CatList();
    void BagInfo();
    void DailyTask();
    void SaveGame();
    void LoadGame();
    void RestNight();
    void NpcDialog(int id);
    void RandomEvent();
    void PlotBook();
    void GameManual();
    void TriggerEnding();
    void PrintLine(string text, int ms = 30);
    void PauseGame();
    int GetValidInput(int min, int max);
    void DeductResource(int& resource, int amount);
    
    // ===================== 工具函数 =====================
    
    // 暂停函数 - 替代 system("pause")
    void PauseGame() {
        cout << "\n按 Enter 键继续...";
        cin.clear();
        cin.ignore(numeric_limits<streamsize>::max(), '\n');
        string dummy;
        getline(cin, dummy);
    }
    
    // 获取有效输入
    int GetValidInput(int min, int max) {
        int input;
        while(true) {
            if(cin >> input) {
                if(input >= min && input <= max) {
                    break;
                }
                cout << "请输入 " << min << " 到 " << max << " 之间的数字: ";
            } else {
                cin.clear();
                cin.ignore(numeric_limits<streamsize>::max(), '\n');
                cout << "请输入有效数字: ";
            }
        }
        return input;
    }
    
    // 安全减少资源(避免负数)
    void DeductResource(int& resource, int amount) {
        if(resource >= amount) {
            resource -= amount;
        } else {
            resource = 0;
        }
    }
    
    // ===================== 主函数 =====================
    int main() {
        srand((unsigned int)time(NULL));
        system("chcp 65001 > nul");
        system("title 猫国:雪夜里的归处");
    
        PrintLine("===== 猫国:雪夜里的归处 文字经营游戏 =====", 50);
        cout << "请输入领主姓名:";
        cin >> game.playerName;
        cout << endl;
        
        cout << "1. 开启全新旅程" << endl;
        cout << "2. 读取存档继续游戏" << endl;
        cout << "3. 查看世界观&操作说明书" << endl;
        
        int op = GetValidInput(1, 3);
    
        if(op == 1) InitGame();
        else if(op == 2) LoadGame();
        else if(op == 3) {
            GameManual();
            PauseGame();
            InitGame();
        }
    
        // 游戏主循环
        while(true) {
            TimePass();
            WeatherRefresh();
            MainCity();
            if(game.plot_ending) break;
        }
    
        PrintLine("\n旅程落幕:感谢你驻守猫国,这里永远是你的雪夜归处。", 50);
        PauseGame();
        return 0;
    }
    
    // ===================== 新游戏初始化 =====================
    void InitGame() {
        game.Init();
        system("cls");
        PrintLine("你在整理奶奶的遗物时,找到了一枚猫形铜钥匙。", 40);
        PrintLine("钥匙背面镌刻着小字:猫国。", 40);
        PrintLine("深夜后院封尘十几年的木门泛起暖黄色光晕。", 40);
        PrintLine("钥匙插入锁孔,咔嗒一声,大门缓缓敞开。", 40);
        PrintLine("裹挟着清甜桂花香的晚风扑面而来,门外是青石板铺就的奇异小城。", 40);
        game.plot_start = true;
        game.eggCount++;
        cout << endl;
        PrintLine("【彩蛋1解锁:铜钥匙的秘密】", 30);
        PauseGame();
    }
    
    // ===================== 时间流逝 =====================
    void TimePass() {
        game.hour++;
        if(game.hour >= 24) {
            game.hour = 6;
            game.day++;
            
            // 安全减少猫粮
            if(game.food >= game.catNum) {
                game.food -= game.catNum;
            } else {
                game.food = 0;
                if(game.catNum > 0) {
                    cout << "\n⚠ 猫粮耗尽,一只猫咪暂时离开猫国觅食..." << endl;
                    game.catNum--;
                    PauseGame();
                }
            }
            
            RandomEvent();
            
            // 触发结局条件
            if(!game.plot_ending && game.fame >= ENDING_FAME && 
               game.catNum >= ENDING_CATS && game.day >= ENDING_DAY) {
                TriggerEnding();
            }
        }
    }
    
    // ===================== 天气刷新 =====================
    void WeatherRefresh() {
        if(game.hour == 8) {
            game.weather = rand() % 4 + 1;
            if(game.plot_ending) game.weather = 4;
        }
    }
    
    // ===================== 主城界面 =====================
    void MainCity() {
        system("cls");
        string timeStr = (game.hour >= 8 && game.hour <= 19) ? "【白昼】" : "【夜幕】";
        string weatherStr;
        switch(game.weather) {
            case 1: weatherStr = "晴空"; break;
            case 2: weatherStr = "阴天"; break;
            case 3: weatherStr = "绵绵小雨"; break;
            case 4: weatherStr = "漫天落雪"; break;
            default: weatherStr = "未知";
        }
    
        cout << "================ 猫国·领主主城 ================" << endl;
        cout << "现任领主:" << game.playerName << "   第" << game.day << "天 " 
             << timeStr << " " << weatherStr << "  " << game.hour << ":00" << endl;
        cout << "声望:" << game.fame << "   金币:" << game.gold 
             << "   储备猫粮:" << game.food << endl;
        cout << "石材:" << game.stone << "   木材:" << game.wood 
             << "   麾下猫咪:" << game.catNum << "只" << endl;
        cout << "生命值:" << game.playerHp << "/" << game.playerMaxHp 
             << "   攻击力:" << game.playerAtk << endl;
        if(game.blessDay > 0) {
            cout << "✨ 神庙祝福生效剩余 " << game.blessDay << " 天" << endl;
        }
        cout << "-------------------------------------------" << endl;
        cout << "1. 居民区漫步招募猫咪   2. 幽暗森林探索物资" << endl;
        cout << "3. 东街集市交易补给     4. 后山矿山采集建材" << endl;
        cout << "5. 山顶神庙祈福许愿     6. 猫咪族群名册查看" << endl;
        cout << "7. 随身背包物品一览     8. 每日委托赚取奖励" << endl;
        cout << "9. 剧情图鉴&彩蛋收集    0. 返回领主府休憩过夜" << endl;
        cout << "请输入数字选择行动:";
    
        int c = GetValidInput(0, 9);
        switch(c) {
            case 0: RestNight(); break;
            case 1: ResidentialArea(); break;
            case 2: Forest(); break;
            case 3: Market(); break;
            case 4: MineArea(); break;
            case 5: Temple(); break;
            case 6: CatList(); break;
            case 7: BagInfo(); break;
            case 8: DailyTask(); break;
            case 9: PlotBook(); break;
        }
    }
    
    // ===================== 居民区 =====================
    void ResidentialArea() {
        system("cls");
        cout << "===== 猫国老居民区 =====" << endl;
        cout << "青石板巷静谧温暖,老猫蜷在墙根晒太阳,空气中弥漫淡淡的鱼干香气。" << endl;
        cout << "1. 与巷口棕耳老猫闲谈往事" << endl;
        cout << "2. 安抚流浪猫,尝试纳入麾下" << endl;
        cout << "3. 返回主城" << endl;
    
        int op = GetValidInput(1, 3);
        if(op == 1) {
            if(!game.plot_oldResident) {
                PrintLine("\n棕耳老猫眯着浑浊的双眼打量你许久,慢悠悠开口:", 35);
                PrintLine("「像,实在太像了。当年老领主也总蹲在这里,给我们分小鱼干。」", 35);
                PrintLine("它讲述了猫国的起源:这片荒地是奶奶一砖一瓦、一草一木搭建起来的。", 35);
                PrintLine("「老领主念叨了好多年,她有个胆小却极爱猫的小孙女,终将继承这座国度。」", 35);
                game.plot_oldResident = true;
                game.eggCount++;
                game.fame += 15;
                cout << endl;
                PrintLine("【彩蛋3解锁:老巷的回忆】", 30);
            } else {
                NpcDialog(rand() % 3 + 1);
            }
            PauseGame();
        }
        else if(op == 2) {
            cout << endl;
            int luck = rand() % 100;
            if(game.weather == 3) luck -= 20;
            if(game.weather == 4) luck -= 10;
            if(game.blessDay > 0) luck += 15;
    
            // 修复:确保不越界
            if(luck >= RECRUIT_THRESHOLD && game.catNum < MAX_CATS) {
                game.catNum++;
                game.catUnlock[game.catNum] = true;
                game.fame += 6;
                cout << "🐱 一只猫咪放下戒备,正式加入猫国。" << endl;
    
                // 白絮剧情
                if(game.catNum == 1 && !game.plot_baiXu) {
                    PrintLine("\n白猫缓步走到脚边,左耳带着一道熟悉的残缺,轻轻蹭着你的裤腿。", 35);
                    PrintLine("你喉头微颤,脱口唤出那个尘封的名字:「白絮?」", 35);
                    PrintLine("它软糯地喵了一声,跨越十几年的时光,回应了你的呼唤。", 35);
                    game.plot_baiXu = true;
                    game.eggCount++;
                    cout << endl;
                    PrintLine("【彩蛋2解锁:左耳的缺口】", 30);
                }
            }
            else if(luck >= 25) {
                game.fame += 3;
                cout << "猫咪对你产生好感,猫国民望小幅提升。" << endl;
            }
            else {
                cout << "今日天气不佳,流浪猫警惕性很高,未能靠近。" << endl;
            }
            PauseGame();
        }
    }
    
    // ===================== 森林 =====================
    void Forest() {
        system("cls");
        cout << "===== 幽暗桂香森林 =====" << endl;
        cout << "密林深处常年萦绕着奶奶院子桂花的甜香,落叶踩踏沙沙作响。" << endl;
        cout << "1. 深入密林探索(有野兽风险)" << endl;
        cout << "2. 外围安全区域捡拾物资" << endl;
        cout << "3. 返回主城" << endl;
    
        int op = GetValidInput(1, 3);
        if(op == 1) {
            if(!game.plot_woodHouse && game.catNum >= 3) {
                PrintLine("\n循着浓郁的桂花香走到森林最深处,一间古朴木屋静静伫立。", 35);
                PrintLine("推门而入,积攒多年的回忆瞬间涌上心头:", 35);
                PrintLine("未织完的儿童围巾、幼年涂鸦画、装满干桂花的玻璃罐,全是奶奶的遗物。", 35);
                PrintLine("白絮跳上窗台扒拉陶罐,你终于记起它为保护你被野狗咬伤耳朵的往事。", 35);
                PrintLine("原来所有陪伴与守护,从来都没有消失。", 35);
                game.plot_woodHouse = true;
                game.eggCount++;
                game.food += 15;
                game.fame += 20;
                cout << endl;
                PrintLine("【彩蛋4解锁:桂花香木屋】", 30);
                PauseGame();
            } else {
                cout << "\n深入密林惊动了野生猛兽,被迫进入战斗!" << endl;
                WildBattle();
            }
        }
        else if(op == 2) {
            int r = rand() % 4;
            if(r == 0) {
                game.food += 8;
                cout << "草丛中找到储备猫粮 ×8。";
            }
            else if(r == 1) {
                game.wood += 12;
                cout << "收集枯木,木材 +12。";
            }
            else if(r == 2) {
                game.gold += 35;
                cout << "发现旅人遗失金币,金币 +35。";
            }
            else {
                game.playerHp -= 15;
                if(game.playerHp < 0) game.playerHp = 0;
                cout << "被毒蛇偷袭,生命值 -15。";
            }
            PauseGame();
        }
    }
    
    // ===================== 集市 =====================
    void Market() {
        system("cls");
        cout << "===== 东街热闹集市 =====" << endl;
        cout << "鱼干、栗子、谷物的香气交织,是奶奶生前最常光顾的地方。" << endl;
    
        if(!game.plot_marketOld) {
            PrintLine("\n集市最内侧摊位,坐着一位胡子花白的老猫商人。", 35);
            PrintLine("它见到你十分激动,无偿赠送最好的鱼味猫粮:老领主一直善待它。", 35);
            PrintLine("一块手工小鱼干递到手中,味道和奶奶亲手制作的完全一致。", 35);
            PrintLine("老猫说,奶奶生前囤积大量猫粮,只为等候你到来的这一天。", 35);
            game.plot_marketOld = true;
            game.eggCount++;
            game.food += 10;
            cout << endl;
            PrintLine("【彩蛋5解锁:鱼干的味道】", 30);
            PauseGame();
        }
    
        cout << "\n1. 采购猫粮(15金币=6袋)    2. 购买疗伤药(25金币/瓶)" << endl;
        cout << "3. 购买捕猎陷阱(30金币/个) 4. 出售木材(8木材=40金币)" << endl;
        cout << "5. 出售石材(10石材=45金币) 6. 离开集市" << endl;
    
        int op = GetValidInput(1, 6);
        if(op == 1) {
            if(game.gold >= 15) {
                game.gold -= 15;
                game.food += 6;
                cout << "购买成功。";
            } else cout << "金币不足。";
        }
        else if(op == 2) {
            if(game.gold >= 25) {
                game.gold -= 25;
                game.medicine++;
                cout << "获得疗伤药水。";
            } else cout << "金币不足。";
        }
        else if(op == 3) {
            if(game.gold >= 30) {
                game.gold -= 30;
                game.trap++;
                cout << "获得捕猎陷阱。";
            } else cout << "金币不足。";
        }
        else if(op == 4) {
            if(game.wood >= 8) {
                game.wood -= 8;
                game.gold += 40;
                cout << "出售完成。";
            } else cout << "木材数量不足。";
        }
        else if(op == 5) {
            if(game.stone >= 10) {
                game.stone -= 10;
                game.gold += 45;
                cout << "出售完成。";
            } else cout << "石材数量不足。";
        }
        PauseGame();
    }
    
    // ===================== 矿山 =====================
    void MineArea() {
        system("cls");
        cout << "===== 后山矿山 =====" << endl;
        if(game.weather == 3 || game.weather == 4) {
            cout << "雨雪天气路面湿滑,无法开展开采工作。" << endl;
            PauseGame();
            return;
        }
        cout << "1. 开采石材   2. 砍伐林木   3. 返回主城" << endl;
        int op = GetValidInput(1, 3);
        if(op == 1) {
            int get = rand() % 8 + 6;
            game.stone += get;
            cout << "成功开采石材 +" << get << endl;
            if(rand() % 10 == 0) {
                PrintLine("\n岩石表面刻着7个歪歪扭扭的小爱心,是奶奶纪念你7岁第一次喂流浪猫留下的印记。", 35);
                game.eggCount++;
                game.fame += 10;
                PrintLine("【彩蛋6解锁:七颗小爱心】", 30);
            }
        }
        else if(op == 2) {
            int get = rand() % 10 + 7;
            game.wood += get;
            cout << "砍伐获得木材 +" << get << endl;
        }
        PauseGame();
    }
    
    // ===================== 神庙 =====================
    void Temple() {
        system("cls");
        cout << "===== 山顶古老神庙 =====" << endl;
        cout << "穿堂风掠过廊柱,发出的声响正是奶奶哼唱的摇篮曲《月光光》。" << endl;
    
        if(!game.plot_templeMural) {
            PrintLine("\n夕阳铺满巨型壁画,完整记录了奶奶的一生与猫国的诞生:", 35);
            PrintLine("从孤身开荒、救助流浪猫,到等待扎羊角辫的小孙女到来。", 35);
            PrintLine("壁画落款小字:愿我的小柚,永远有猫相伴,永远有归处。", 35);
            PrintLine("壁画顶端,挂着铃铛的橘猫橘子静静蹲坐,它早已在此等候祖孙二人。", 35);
            game.plot_templeMural = true;
            game.eggCount++;
            game.blessDay += 7;
            game.fame += 30;
            cout << endl;
            PrintLine("【彩蛋7解锁:壁画里的时光】", 30);
            PauseGame();
        }
    
        cout << "\n1. 供奉祈福(60金币,获得5天招募加成)   2. 离开神庙" << endl;
        int op = GetValidInput(1, 2);
        if(op == 1) {
            if(game.gold >= 60) {
                game.gold -= 60;
                game.blessDay += 5;
                cout << "祈福完成,后续招募猫咪成功率提升。" << endl;
            } else cout << "所持金币不足,无法供奉。";
        }
        PauseGame();
    }
    
    // ===================== 战斗系统 =====================
    void WildBattle() {
        int enemyHp, enemyAtk;
        int type = rand() % 3;
        string eName;
        if(type == 0) { enemyHp = 75; enemyAtk = 14; eName = "黑纹野猫"; }
        else if(type == 1) { enemyHp = 110; enemyAtk = 20; eName = "丛林恶狼"; }
        else { enemyHp = 140; enemyAtk = 26; eName = "野猪"; }
        cout << "遭遇敌对生物:" << eName << endl;
    
        while(enemyHp > 0 && game.playerHp > 0) {
            cout << "\n你的生命值:" << game.playerHp << "  敌方生命值:" << enemyHp << endl;
            cout << "1. 普通攻击   2. 使用陷阱   3. 使用药水回血" << endl;
            int c = GetValidInput(1, 3);
            if(c == 1) {
                enemyHp -= game.playerAtk;
                cout << "攻击生效,敌方生命值 -" << game.playerAtk << endl;
                if(enemyHp > 0) {
                    game.playerHp -= enemyAtk;
                    if(game.playerHp < 0) game.playerHp = 0;
                    cout << "敌人反击,你的生命值 -" << enemyAtk << endl;
                }
            }
            else if(c == 2) {
                if(game.trap >= 1) {
                    game.trap--;
                    enemyHp -= 60;
                    cout << "陷阱触发!敌方生命值 -60" << endl;
                } else cout << "背包内没有剩余陷阱。";
            }
            else if(c == 3) {
                if(game.medicine >= 1) {
                    game.medicine--;
                    game.playerHp += 45;
                    if(game.playerHp > game.playerMaxHp) game.playerHp = game.playerMaxHp;
                    cout << "生命值恢复完毕。";
                } else cout << "没有疗伤药水了。";
            }
        }
    
        if(game.playerHp <= 0) {
            cout << "\n身负重伤逃回主城,损失30%金币作为疗伤费用。" << endl;
            game.gold = (int)(game.gold * 0.7);
            game.playerHp = 35;
        } else {
            int reward = rand() % 60 + 40;
            game.gold += reward;
            game.fame += 10;
            cout << "\n战斗胜利!获得金币+" << reward << ",猫国声望提升。" << endl;
        }
        PauseGame();
    }
    
    // ===================== 猫咪名册 =====================
    void CatList() {
        system("cls");
        cout << "===== 猫国族群名册 =====" << endl;
        if(game.catNum == 0) {
            cout << "暂无归属猫咪,前往居民区可以招募伙伴。" << endl;
        } else {
            for(int i = 1; i <= MAX_CATS; i++) {
                if(game.catUnlock[i]) {
                    cout << catName[i] << "  | 等级:" << game.catLevel[i] << endl;
                }
            }
            cout << "\n总计在册猫咪数量:" << game.catNum << " 只" << endl;
        }
        PauseGame();
    }
    
    // ===================== 背包 =====================
    void BagInfo() {
        system("cls");
        cout << "===== 领主随身背包 =====" << endl;
        cout << "疗伤药水:" << game.medicine << " 瓶" << endl;
        cout << "捕猎陷阱:" << game.trap << " 个" << endl;
        cout << "储备猫粮:" << game.food << " 袋" << endl;
        cout << "木材:" << game.wood << "  石材:" << game.stone << endl;
        cout << "持有金币:" << game.gold << endl;
        cout << "已收集彩蛋数量:" << game.eggCount << " / " << MAX_EGGS << endl;
        PauseGame();
    }
    
    // ===================== 每日任务 =====================
    void DailyTask() {
        system("cls");
        cout << "===== 猫国每日委托 =====" << endl;
        cout << "委托内容:前往森林击退一头野兽,保障区域安全" << endl;
        cout << "任务奖励:金币80,声望20" << endl;
        cout << "1. 确认接取并完成  2. 放弃委托" << endl;
        int op = GetValidInput(1, 2);
        if(op == 1) {
            game.gold += 80;
            game.fame += 20;
            cout << "委托结算完成,奖励已自动存入背包。" << endl;
        }
        PauseGame();
    }
    
    // ===================== 存档 =====================
    void SaveGame() {
        ofstream out("catKingdom_save.txt");
        if(!out) {
            cout << "❌ 存档失败!" << endl;
            return;
        }
        out << game.day << " " << game.hour << " " << game.fame << " " 
            << game.gold << " " << game.food << " " << game.stone << " " << game.wood << endl;
        out << game.catNum << " " << game.medicine << " " << game.trap << " " 
            << game.blessDay << " " << game.playerHp << " " << game.playerMaxHp << " " << game.playerAtk << endl;
        out << game.plot_start << " " << game.plot_baiXu << " " << game.plot_oldResident << " " 
            << game.plot_woodHouse << " ";
        out << game.plot_marketOld << " " << game.plot_templeMural << " " 
            << game.plot_ending << " " << game.eggCount << endl;
        for(int i = 1; i <= MAX_CATS; i++) {
            out << game.catUnlock[i] << " " << game.catLevel[i] << " ";
        }
        out.close();
        cout << "✅ 游戏存档已保存至 catKingdom_save.txt" << endl;
        PauseGame();
    }
    
    // ===================== 读档 =====================
    void LoadGame() {
        ifstream in("catKingdom_save.txt");
        if(!in) {
            cout << "未检测到存档文件,自动开启新旅程。" << endl;
            PauseGame();
            InitGame();
            return;
        }
        
        // 读取数据并进行基本验证
        if(!(in >> game.day >> game.hour >> game.fame >> game.gold >> game.food 
             >> game.stone >> game.wood)) {
            cout << "❌ 存档文件损坏,自动开启新旅程。" << endl;
            PauseGame();
            InitGame();
            return;
        }
        
        // 验证数据合理性
        if(game.day < 1 || game.hour < 0 || game.hour > 23 || game.fame < 0) {
            cout << "❌ 存档数据异常,自动开启新旅程。" << endl;
            PauseGame();
            InitGame();
            return;
        }
        
        in >> game.catNum >> game.medicine >> game.trap >> game.blessDay 
           >> game.playerHp >> game.playerMaxHp >> game.playerAtk;
        in >> game.plot_start >> game.plot_baiXu >> game.plot_oldResident >> game.plot_woodHouse;
        in >> game.plot_marketOld >> game.plot_templeMural >> game.plot_ending >> game.eggCount;
        for(int i = 1; i <= MAX_CATS; i++) {
            in >> game.catUnlock[i] >> game.catLevel[i];
        }
        in.close();
        
        // 限制猫咪数量不超过最大值
        if(game.catNum > MAX_CATS) game.catNum = MAX_CATS;
        
        cout << "✅ 存档读取成功,欢迎再次回到猫国。" << endl;
        PauseGame();
    }
    
    // ===================== 夜晚休憩 =====================
    void RestNight() {
        game.hour = 7;
        game.playerHp = game.playerMaxHp;
        SaveGame();
        cout << "你在领主府安稳熟睡,生命值完全恢复,游戏自动存档。" << endl;
        
        if(game.plot_templeMural && rand() % 5 == 0) {
            PrintLine("\n清晨睁眼,窗台上趴着一只挂铃铛的圆滚滚橘猫,静静注视着你。", 35);
            PrintLine("它对视片刻,便纵身跃入晨光之中,那是一直默默守望你的橘子。", 35);
            game.eggCount++;
            PrintLine("【彩蛋8解锁:窗台的守望】", 30);
        }
        PauseGame();
    }
    
    // ===================== NPC对话 =====================
    void NpcDialog(int id) {
        if(id == 1) cout << "老猫提醒:森林野兽较强,外出探索记得携带陷阱。" << endl;
        else if(id == 2) cout << "老猫提醒:晴天、雪天猫咪更容易被招募,雨天招募难度会上升。" << endl;
        else if(id == 3) cout << "老猫提醒:神庙的祝福,可以大幅提升流浪猫的归顺概率。" << endl;
    }
    
    // ===================== 随机事件 =====================
    void RandomEvent() {
        int e = rand() % 5;
        if(e == 0) { game.food += 12; cout << "\n【随机事件】远方旅人捐赠猫粮 ×12"; }
        else if(e == 1) { game.gold += 55; cout << "\n【随机事件】过路商人赠予金币 ×55"; }
        else if(e == 2) { game.fame += 15; cout << "\n【随机事件】猫国美名传播,声望+15"; }
        else if(e == 3) { 
            int loss = (game.food >= 7) ? 7 : game.food;
            game.food -= loss;
            cout << "\n【随机事件】小野猫夜间偷吃猫粮,猫粮-" << loss; 
        }
        // e==4 无事件
    }
    
    // ===================== 剧情图鉴 =====================
    void PlotBook() {
        system("cls");
        cout << "===== 剧情图鉴 & 全" << MAX_EGGS << "彩蛋收集进度 =====" << endl;
        cout << "已解锁彩蛋:" << game.eggCount << " / " << MAX_EGGS << "\n" << endl;
        cout << "1. 铜钥匙的秘密(开启猫国大门)........" << (game.plot_start ? "✅" : "❌") << endl;
        cout << "2. 左耳的缺口(与白絮重逢)............" << (game.plot_baiXu ? "✅" : "❌") << endl;
        cout << "3. 老巷的回忆(棕耳老猫口述历史)......" << (game.plot_oldResident ? "✅" : "❌") << endl;
        cout << "4. 桂花香木屋(森林深处奶奶旧物)......" << (game.plot_woodHouse ? "✅" : "❌") << endl;
        cout << "5. 鱼干的味道(集市老猫商的馈赠)......" << (game.plot_marketOld ? "✅" : "❌") << endl;
        cout << "6. 七颗小爱心(矿山岩石刻痕).......... " << (game.eggCount >= 6 ? "✅" : "❌") << endl;
        cout << "7. 壁画里的时光(神庙完整壁画)........" << (game.plot_templeMural ? "✅" : "❌") << endl;
        cout << "8. 窗台的守望(橘猫橘子深夜探望)......" << (game.eggCount >= 8 ? "✅" : "❌") << endl;
        cout << "9. 雪夜的南瓜蛋糕(最终生日结局)......" << (game.plot_ending ? "✅" : "❌") << endl;
        cout << "\n💡 通关提示:攒够" << ENDING_FAME << "声望、" << ENDING_CATS 
             << "只以上猫咪、第" << ENDING_DAY << "天之后自动触发最终结局。" << endl;
        PauseGame();
    }
    
    // ===================== 说明书 =====================
    void GameManual() {
        system("cls");
        cout << "==================== 游戏完整说明书 ====================" << endl;
        cout << "【世界观核心】" << endl;
        cout << "猫国是由人类思念、善意与爱意凝聚的异次元空间,所有被温柔善待的猫咪都会在此永生安居。" << endl;
        cout << "整片国度的场景,完全复刻了主角奶奶现实一生的生活轨迹。" << endl << endl;
        cout << "【基础玩法】" << endl;
        cout << "1. 每次行动消耗1小时,每24小时为1天,每日自动消耗猫粮喂养猫咪;" << endl;
        cout << "2. 居民区招募猫咪、森林/矿山获取资源、集市交易物资;" << endl;
        cout << "3. 推进主线剧情解锁回忆彩蛋,神庙祈福提升招募成功率;" << endl;
        cout << "4. 满足条件触发雪夜生日终章,完成整个故事闭环。" << endl << endl;
        cout << "【通关目标】收集全部" << MAX_EGGS << "个彩蛋,解锁奶奶留给阿柚的全部温柔回忆。" << endl;
        cout << "========================================================" << endl;
    }
    
    // ===================== 最终结局 =====================
    void TriggerEnding() {
        game.plot_ending = true;
        game.weather = 4;
        game.eggCount++;
        system("cls");
    
        PrintLine("猫国的第一场大雪,轻飘飘覆盖了整座青石板小城。", 40);
        PrintLine("你推开领主府大门,所有猫咪整齐聚集在中央广场等候。", 40);
        PrintLine("广场正中摆放着温热的南瓜生日蛋糕,插着摇曳的蜡烛。", 40);
        PrintLine("老猫商笑着说道:这是老领主提前教会我们,为你准备的生日惊喜。", 40);
        PrintLine("白絮叼来一个布包,里面是奶奶的老花镜,还有一纸亲笔留言:", 40);
        PrintLine("「小柚,猫咪们会代替我永远陪伴你,这里永远是你的退路与归处。」", 40);
        PrintLine("雪花落满蓬松的猫毛,温暖包裹着整个世界。", 40);
        PrintLine("吹灭蜡烛的瞬间,你仿佛看见奶奶站在城门下,温柔挥手,消融在落雪里。", 40);
        PrintLine("离别从不是终点,爱过的人会化作风、花香、满城猫咪,永远守护着你。", 40);
        PrintLine("猫国永存灯火,你永远拥有雪夜里的归处。", 40);
    
        cout << endl;
        PrintLine("【彩蛋9解锁:雪夜的南瓜蛋糕 · 游戏完美通关】", 30);
        PauseGame();
    }
    
    // ===================== 文字特效 =====================
    void PrintLine(string text, int ms) {
        for(char c : text) {
            cout << c;
            Sleep(ms);
        }
        cout << endl;
    }
    

    三、使用说明

    1. 编译运行:复制全部代码,使用 Dev-C++ / VS2019+/CodeBlocks(Windows) 直接编译,无需额外库;

    2. 存档文件:运行后自动生成 catKingdom_save.txt,下次选择「读取存档」即可继续进度;

    3. 通关条件:游戏第15天之后、声望≥200、猫咪数量≥8,自动触发大结局;

    4. 彩蛋收集:共9枚彩蛋,分布在序章、各区域主线、矿山随机触发、夜晚休憩、结局之中,可在【剧情图鉴】查看收集进度。 完结

    代码

    \\\\ \\ \\ \\ \\ \\ \\        _ooOoo_          // // // // // // ////
    \\\\ \\ \\ \\ \\ \\          o8888888o            // // // // // ////
    \\\\ \\ \\ \\ \\             88" . "88               // // // // ////
    \\\\ \\ \\ \\                (| -_- |)                  // // // ////
    \\\\ \\ \\                   O\  =  /O                     // // ////
    \\\\ \\                   ____/`---'\____                     // ////
    \\\\                    .'  \\|     |//  `.                      ////
    //==                   /  \\|||  :  |||//  \                     ==\\
    //==                  /  _||||| -:- |||||-  \                    ==\\
    //==                  |   | \\\  -  /// |   |                    ==\\
    //==                  | \_|  ''\---/''  |   |                    ==\\
    //==                  \  .-\__  `-`  ___/-. /                    ==\\
    //==                ___`. .'  /--.--\  `. . ___                  ==\\
    //==             ."" '<  `.___\_<|>_/___.'  >' "".               ==\\
    //==            | | :  `- \`.;`\ _ /`;.`/ - ` : | |              \\\\
    ////            \  \ `-.   \_ __\ /__ _/   .-` /  /              \\\\
    ////      ========`-.____`-.___\_____/___.-`____.-'========      \\\\
    ////                           `=---='                           \\\\
    //// //   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  \\ \\\\
    //// // //      佛祖保佑      永无BUG      永不修改        \\ \\ \\\\
    //// // // // // // || || || || || || || || || || \\ \\ \\ \\ \\ \\\\
    
    
    sb
    

    代码部分

    贪吃蛇

    #include <iostream>
    #include <windows.h>
    #include <conio.h>
    #include <cstdlib>
    #include <ctime>
    using namespace std;   //五一爆肝的贪吃蛇代码
    
    // 超大地图
    const int width = 60;
    const int height = 25;
    const int FOOD_NUM = 8;   // 食物数量,可改
    
    bool gameOver;
    bool pause = false;
    int gameMode;   // 1单人 2双人
    
    // 蛇1 变量
    int x1, y1;
    int tailX1[200], tailY1[200];
    int nTail1;
    
    // 蛇2 变量
    int x2, y2;
    int tailX2[200], tailY2[200];
    int nTail2;
    
    int score1, score2;
    int fruitX[FOOD_NUM], fruitY[FOOD_NUM];
    
    enum Dir { STOP = 0, LEFT, RIGHT, UP, DOWN };
    Dir dir1, dir2;
    
    void gotoxy(int x, int y) {
        COORD pos;
        pos.X = x;
        pos.Y = y;
        SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), pos);
    }
    
    void HideCursor() {
        CONSOLE_CURSOR_INFO ci = { 1, 0 };
        SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE), &ci);
    }
    
    void spawnFood(int idx) {
        fruitX[idx] = rand() % width;
        fruitY[idx] = rand() % height;
    }
    
    // 初始化游戏
    void Setup() {
        gameOver = false;
        pause = false;
        dir1 = STOP;
        dir2 = STOP;
    
        // 蛇1初始位置 左边
        x1 = 10; y1 = height / 2;
        // 蛇2初始位置 右边
        x2 = width - 10; y2 = height / 2;
    
        score1 = 0;
        score2 = 0;
        nTail1 = 0;
        nTail2 = 0;
    
        // 生成多个食物
        for (int i = 0; i < FOOD_NUM; i++)
            spawnFood(i);
    
        HideCursor();
    }
    
    // 绘制超大地图
    void Draw() {
        gotoxy(0, 0);
        // 上边框
        for (int i = 0; i < width + 2; i++) cout << "#";
        cout << endl;
    
        for (int i = 0; i < height; i++) {
            for (int j = 0; j < width; j++) {
                if (j == 0) cout << "#";
    
                // 蛇1头 O
                if (i == y1 && j == x1)
                    cout << "O";
                // 蛇2头 X
                else if (i == y2 && j == x2 && gameMode == 2)
                    cout << "X";
                else {
                    bool isF = false;
                    // 画所有食物
                    for (int k = 0; k < FOOD_NUM; k++) {
                        if (fruitY[k] == i && fruitX[k] == j) {
                            cout << "F";
                            isF = true;
                            break;
                        }
                    }
                    if (isF) continue;
    
                    // 蛇1身体
                    bool body1 = false;
                    for (int k = 0; k < nTail1; k++) {
                        if (tailX1[k] == j && tailY1[k] == i) {
                            cout << "o";
                            body1 = true;
                        }
                    }
                    if (body1) continue;
    
                    // 蛇2身体
                    bool body2 = false;
                    if (gameMode == 2) {
                        for (int k = 0; k < nTail2; k++) {
                            if (tailX2[k] == j && tailY2[k] == i) {
                                cout << "x";
                                body2 = true;
                            }
                        }
                    }
                    if (!body2) cout << " ";
                }
    
                if (j == width - 1) cout << "#";
            }
            cout << endl;
        }
        // 下边框
        for (int i = 0; i < width + 2; i++) cout << "#";
        cout << endl;
    
        cout << "玩家1分数:" << score1;
        if (gameMode == 2) cout << "     玩家2分数:" << score2;
        cout << "     空格=暂停/继续   X=退出" << endl;
        if (pause) cout << "【游戏已暂停,按空格继续】" << endl;
    }
    
    // 按键监听
    void Input() {
        if (_kbhit()) {
            switch (_getch()) {
                // 玩家1 WASD
                case 'a': if (dir1 != RIGHT) dir1 = LEFT; break;
                case 'd': if (dir1 != LEFT)  dir1 = RIGHT; break;
                case 'w': if (dir1 != DOWN)  dir1 = UP;    break;
                case 's': if (dir1 != UP)    dir1 = DOWN;  break;
    
                // 玩家2 方向键 仅双人模式
                case 72: if (gameMode==2 && dir2!=DOWN) dir2=UP;    break;
                case 80: if (gameMode==2 && dir2!=UP)   dir2=DOWN;  break;
                case 75: if (gameMode==2 && dir2!=RIGHT)dir2=LEFT;  break;
                case 77: if (gameMode==2 && dir2!=LEFT) dir2=RIGHT; break;
    
                case 'x': gameOver = true; break;
                case ' ': pause = !pause;  break;
            }
        }
    }
    
    // 蛇1逻辑
    void Logic1() {
        int px = tailX1[0], py = tailY1[0];
        int px2, py2;
        tailX1[0] = x1; tailY1[0] = y1;
        for (int i = 1; i < nTail1; i++) {
            px2 = tailX1[i]; py2 = tailY1[i];
            tailX1[i] = px;  tailY1[i] = py;
            px = px2; py = py2;
        }
    
        if(!pause){
            switch (dir1) {
                case LEFT: x1--; break;
                case RIGHT:x1++; break;
                case UP:   y1--; break;
                case DOWN: y1++; break;
                default:break;
            }
        }
    
        // 撞墙
        if (x1<0 || x1>=width || y1<0 || y1>=height)
            gameOver = true;
        // 撞自己
        for (int i = 0; i < nTail1; i++)
            if (tailX1[i]==x1 && tailY1[i]==y1)
                gameOver = true;
    
        // 吃食物
        for (int k = 0; k < FOOD_NUM; k++) {
            if (x1==fruitX[k] && y1==fruitY[k]) {
                score1 += 10;
                nTail1++;
                spawnFood(k);
            }
        }
    }
    
    // 蛇2逻辑
    void Logic2() {
        int px = tailX2[0], py = tailY2[0];
        int px2, py2;
        tailX2[0] = x2; tailY2[0] = y2;
        for (int i = 1; i < nTail2; i++) {
            px2 = tailX2[i]; py2 = tailY2[i];
            tailX2[i] = px;  tailY2[i] = py;
            px = px2; py = py2;
        }
    
        if(!pause){
            switch (dir2) {
                case LEFT: x2--; break;
                case RIGHT:x2++; break;
                case UP:   y2--; break;
                case DOWN: y2++; break;
                default:break;
            }
        }
    
        if (x2<0 || x2>=width || y2<0 || y2>=height)
            gameOver = true;
        for (int i = 0; i < nTail2; i++)
            if (tailX2[i]==x2 && tailY2[i]==y2)
                gameOver = true;
    
        for (int k = 0; k < FOOD_NUM; k++) {
            if (x2==fruitX[k] && y2==fruitY[k]) {
                score2 += 10;
                nTail2++;
                spawnFood(k);
            }
        }
    }
    
    // 模式选择界面
    void SelectMode() {
        system("cls");
        cout << "========== 贪吃蛇 模式选择 ==========" << endl;
        cout << "         1. 单人模式" << endl;
        cout << "         2. 双人模式" << endl;
        cout << "====================================" << endl;
        cout << "请输入 1 或 2 选择:";
        cin >> gameMode;
        while(gameMode != 1 && gameMode != 2){
            cout << "输入错误,请重新输入 1 或 2:";
            cin >> gameMode;
        }
        system("cls");
    }
    
    // 游戏说明
    void ShowHelp() {
        system("cls");
        cout << "==================== 游戏说明 ====================" << endl;
        cout << "【玩家1】控制:W(上) A(左) S(下) D(右)" << endl;
        cout << "【玩家2】控制:↑ ↓ ← → 方向键(双人专用)" << endl;
        cout << "空格键:暂停 / 继续" << endl;
        cout << "X键:退出游戏" << endl;
        cout << "吃到F加分变长,撞墙/撞身体游戏结束" << endl;
        cout << "==================================================" << endl;
        cout << "按任意键开始...";
        _getch();
        system("cls");
    }
    
    int main() {
        SelectMode();    // 选单人/双人
        ShowHelp();      // 游戏说明
        Setup();         // 初始化
    
        while (!gameOver) {
            Draw();
            Input();
            Logic1();
            if (gameMode == 2) Logic2();
            Sleep(40);   // 延迟小、速度快,嫌快就改60、80
        }
    
        system("cls");
        cout << "游戏结束!" << endl;
        cout << "玩家1最终分数:" << score1 << endl;
        if(gameMode == 2) cout << "玩家2最终分数:" << score2 << endl;
        Sleep(3000);
        return 0;
    }
    

    飞船大战

    #include <iostream>
    #include <conio.h>
    #include <windows.h>
    #include <cstdlib>
    #include <ctime>
    using namespace std;
    
    const int WIDTH = 45;
    const int HEIGHT = 22;
    
    // 玩家飞船左上角坐标
    int px, py;
    // 子弹
    int bx, by;
    bool haveBullet;
    // 敌机左上角坐标
    int ex, ey;
    int score;
    
    // 隐藏光标
    void HideCursor()
    {
        CONSOLE_CURSOR_INFO ci;
        ci.dwSize = 1;
        ci.bVisible = FALSE;
        SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE), &ci);
    }
    
    // 光标定位
    void GoTo(int x, int y)
    {
        COORD p;
        p.X = x; p.Y = y;
        SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), p);
    }
    
    // 初始化
    void Init()
    {
        px = WIDTH / 2 - 1;
        py = HEIGHT - 3;
    
        haveBullet = false;
        bx = 0; by = 0;
    
        ex = rand() % (WIDTH - 3);
        ey = 0;
    
        score = 0;
        HideCursor();
        system("cls");
    }
    
    // 绘制大号飞船
    void Draw()
    {
        GoTo(0, 0);
        // 上边框
        for(int i = 0; i < WIDTH + 4; i++) cout << "#";
        cout << endl;
    
        for(int y = 0; y < HEIGHT; y++)
        {
            cout << "#";
            for(int x = 0; x < WIDTH; x++)
            {
                bool flag = false;
    
                // 玩家大号飞船造型
                if(y == py && x == px)      cout << "▲", flag = 1;
                else if(y == py+1 && x == px-1) cout << "<", flag = 1;
                else if(y == py+1 && x == px)   cout << "◆", flag = 1;
                else if(y == py+1 && x == px+1) cout << ">", flag = 1;
    
                // 子弹
                else if(haveBullet && x == bx && y == by)
                    cout << "|", flag = 1;
    
                // 大号敌机
                else if(y == ey && x == ex)        cout << "@", flag = 1;
                else if(y == ey && x == ex+1)      cout << "@", flag = 1;
                else if(y == ey && x == ex+2)      cout << "@", flag = 1;
                else if(y == ey+1 && x == ex+1)    cout << "▼", flag = 1;
    
                if(!flag) cout << " ";
            }
            cout << "#\n";
        }
        // 下边框
        for(int i = 0; i < WIDTH + 4; i++) cout << "#";
        cout << "\n分数:" << score;
    }
    
    // 按键控制
    void Key()
    {
        if(_kbhit())
        {
            char c = _getch();
            switch(c)
            {
                case 'a': case 'A': if(px > 2) px--; break;
                case 'd': case 'D': if(px < WIDTH-3) px++; break;
                case 'w': case 'W': if(py > 1) py--; break;
                case 's': case 'S': if(py < HEIGHT-4) py++; break;
                case ' ':
                    if(!haveBullet)
                    {
                        haveBullet = true;
                        bx = px;
                        by = py - 1;
                    }
                    break;
            }
        }
    }
    
    // 子弹移动
    void BulletRun()
    {
        if(haveBullet)
        {
            by--;
            if(by < 0) haveBullet = false;
        }
    }
    
    // 敌机移动
    void EnemyRun()
    {
        ey++;
        if(ey >= HEIGHT - 2)
        {
            ey = 0;
            ex = rand() % (WIDTH - 3);
        }
    }
    
    // 碰撞检测
    bool Crash()
    {
        // 子弹打敌机
        if(haveBullet)
        {
            if(by == ey && (bx >= ex && bx <= ex+2))
            {
                score += 10;
                ey = 0;
                ex = rand() % (WIDTH - 3);
                haveBullet = false;
            }
        }
    
        // 飞船撞敌机
        if( (py <= ey+1) && (py+1 >= ey) )
        {
            if( (px-1 <= ex+2) && (px+1 >= ex) )
                return true;
        }
        return false;
    }
    
    int main()
    {
        srand((unsigned)time(NULL));
        Init();
        while(1)
        {
            Draw();
            Key();
            BulletRun();
            EnemyRun();
            if(Crash())
            {
                GoTo(15, HEIGHT/2);
                cout << "游戏结束!最终分数:" << score << endl;
                break;
            }
            Sleep(70);
        }
        return 0;
    }
    

    绝地狂态(原版)

    #include<bits/stdc++.h>
    #include<windows.h>
    #include<stdio.h>
    #include<conio.h>
    #include<time.h>
    #define KEY_DOWN(VK_NONAME)((GetAsyncKeyState(VK_NONAME)&0x8000)?1:0)
    using namespace std;
    int m[10001][21];
    struct node {int xx,yy,Zhong,rr,mr;} B[100001];
    int K,X,Y,tX,tY,tY2,tT,Er,T,Yb,Zb,Win,Blood,Score,Kb;
    void Color(int a)
    {
        if(a==0) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE);
        if(a==1) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_GREEN|FOREGROUND_BLUE);
        if(a==2) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_GREEN);
        if(a==3) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_BLUE);
        if(a==4) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED);
        if(a==5) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_GREEN);
        if(a==6) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_BLUE);
        if(a==7) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_RED|FOREGROUND_GREEN);
        if(a==8) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE);
        if(a==9) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_GREEN|BACKGROUND_INTENSITY|BACKGROUND_RED);
        if(a==10) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_GREEN|FOREGROUND_BLUE|BACKGROUND_INTENSITY|BACKGROUND_BLUE);
    }
    void SetPos(int x,int y)
    {
        COORD pos; pos.X=y*2-1,pos.Y=x+1;
        SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),pos);
    }
    void Zha(int x,int y)
    {
        Zb++;
        int k1=rand()%2+2,k2=rand()%3+2,r=rand()%6;
        if(r==0) B[Zb].xx=x-K,B[Zb].yy=y,B[Zb].Zhong=1,B[Zb].rr=0,B[Zb].mr=k1*2;
        if(r==1) B[Zb].xx=x-K,B[Zb].yy=y,B[Zb].Zhong=2;
        if(r==2) B[Zb].xx=x-K,B[Zb].yy=y,B[Zb].Zhong=3,B[Zb].rr=k2,B[Zb].mr=k1;
        if(r==3) B[Zb].xx=x-K,B[Zb].yy=y,B[Zb].Zhong=4;
        if(r==4) B[Zb].xx=x-K,B[Zb].yy=y,B[Zb].Zhong=5,B[Zb].rr=1,B[Zb].mr=k2*2;
        if(r==5) B[Zb].xx=x-K,B[Zb].yy=y,B[Zb].Zhong=rand()%2+6,B[Zb].rr=k1+1,B[Zb].mr=k2+3;
    }
    void Cout(int i,int j,int a)
    {
        int R=rand()%500,jk=0;
        if(i-K>=0&&i-K<=1&&j>=2&&j<=6) return;
        if(a!=4)
        {
        if(m[i][j]==0&&(a==0||a==3)) SetPos(i-K,j),Color(7),cout<<"■";
        if(m[i][j]==1&&a==5) SetPos(i-K,j),Color(0),cout<<"  ";//空气 
        if(m[i][j]==2) SetPos(i-K,j),Color(8),cout<<"■";
        if(m[i][j]>=3&&m[i][j]<6) SetPos(i-K,j),Color(5),cout<<"█",m[i][j]++;
        if(m[i][j]==6&&a!=5) SetPos(i-K,j),cout<<"  ",m[i][j]=1;
        if(m[i][j]==7) SetPos(i-K,j),Color(9),cout<<"~ ";
        if(m[i][j]==8) SetPos(i-K,j),Color(10),cout<<"~ ";
        if(m[i][j]==9) SetPos(i-K,j),Color(3),cout<<"◆";
        if((m[i][j]==1||m[i][j]==8)&&m[i-1][j]>=10&&m[i-1][j]<=30&&a!=5) {int M=m[i][j];m[i][j]=m[i-1][j],m[i-1][j]=M;if(M==1) SetPos(i-K-1,j),cout<<"  ";}//炸弹下落 
        if(m[i][j]==1&&m[i-1][j]==9&&a!=5) {m[i][j]=9,m[i-1][j]=1,SetPos(i-K-1,j),Color(0),cout<<"  ";jk=1;}//宝石下落
        if(m[i][j]>=10&&m[i][j]<=30) {m[i][j]++;if(m[i][j]%3==0) Color(4);else Color(5);SetPos(i-K,j),cout<<"●";}//炸弹计时
        if(m[i][j]==1&&m[i-1][j]==7&&a!=5) {m[i][j]=7,m[i-1][j]=1,SetPos(i-K-1,j),Color(0),cout<<"  ";jk=1;}//岩浆下落
        if(m[i][j]==0&&m[i-1][j]==7&&R<=2) m[i][j]=m[i-1][j],m[i-1][j]=1,SetPos(i-K-1,j),cout<<"  ";//岩浆融解 
        if(m[i][j]==7&&R>2&&R<=5) {int r=rand()%3-1; if(m[i][j+r]==1) m[i][j+r]=m[i][j];if(m[i][j+r]==8) m[i][j+r]=2;}//岩浆扩散  
        if(R<50&&R>=20&&m[i+1][j+1]==1&&m[i+1][j]==8&&m[i][j]==8) m[i+1][j+1]=8,m[i][j]=1,SetPos(i-K,j),Color(0),cout<<"  ";
        if(R<80&&R>=50&&m[i+1][j-1]==1&&m[i+1][j]==8&&m[i][j]==8) m[i+1][j-1]=8,m[i][j]=1,SetPos(i-K,j),Color(0),cout<<"  ";//岩浆平面 
        if(m[i][j]==1&&m[i-1][j]==8&&a!=5) {m[i][j]=8,m[i-1][j]=1,SetPos(i-K-1,j),Color(0),cout<<"  ";jk=1;}//水下落
        if(m[i+1][j+1]==1&&m[i+1][j]==8&&m[i][j]==8) m[i+1][j+1]=8,m[i][j]=1,SetPos(i-K,j),Color(0),cout<<"  ";
        if(m[i+1][j-1]==1&&m[i+1][j]==8&&m[i][j]==8) m[i+1][j-1]=8,m[i][j]=1,SetPos(i-K,j),Color(0),cout<<"  ";//水平面 
        if((m[i+1][j]==8&&m[i][j]==7)||(m[i+1][j]==7&&m[i][j]==8)) m[i][j]=2,m[i-1][j]=1,SetPos(i-K-1,j),Color(0),cout<<"  ";//变石头
        if(m[i][j]==0&&m[i-1][j]==8&&R>5&&R<=7) m[i][j]=m[i-1][j],m[i-1][j]=1,SetPos(i-K-1,j),cout<<"  ";//水融解 
        if(m[i][j]==8&&R>7&&R<=9) {int r=rand()%3-1; if(m[i][j+r]==1) m[i][j+r]=m[i][j];if(m[i][j+r]==7) m[i][j+r]=2;}//水扩散  
        if(m[i][j]==31) SetPos(i-K,j),cout<<"  ",Zha(i,j);
        }
        else if(a!=5)//界外 
        {
            if(m[i][j]>=3&&m[i][j]<6) m[i][j]++; if(m[i][j]==6) m[i][j]=1;
            if((m[i][j]==1||(m[i][j]>=3&&m[i][j]<=6))&&m[i-1][j]>=10&&m[i-1][j]<=30) m[i][j]=m[i-1][j],m[i-1][j]=1;//炸弹下落 
            if(m[i][j]>=10&&m[i][j]<=30) m[i][j]++;//炸弹计时
            if(m[i][j]==1&&m[i-1][j]==9) m[i][j]=9,m[i-1][j]=1;//宝石下落
            if(m[i][j]==1&&m[i-1][j]==7) m[i][j]=7,m[i-1][j]=1;//岩浆下落
            if(m[i][j]==1&&m[i-1][j]==8) m[i][j]=8,m[i-1][j]=1;//水下落
        }if(jk==1) jk=0,Cout(i,j,5);
        Color(0);
    }
    void Map(int a);
    void Wo()
    {
        SetPos(X-K,Y),cout<<"  "; //清除上一次残影
        if(m[X][Y]==9) Blood++,Score+=5,m[X][Y]=1,system("color 2F"),Sleep(50),system("color 0F"),Map(3);
        if(tX!=0&&(m[X-1][Y]==1||m[X-1][Y]==7||m[X-1][Y]==8||m[X-1][Y]==9||(m[X-1][Y]>=3&&m[X-1][Y]<=6))) tX--,X-=2;  //上跳 
        if(m[X+1][Y]==1||(m[X+1][Y]>=3&&m[X+1][Y]<=6)||m[X+1][Y]==7||m[X+1][Y]==8||m[X+1][Y]==9) X++; //掉落 
        if(m[X+1][Y]==0||m[X+1][Y]==2||(m[X+1][Y]>=3&&m[X+1][Y]<=6)) tX=Er=0; //跳跃次数清零 
        if(m[X-1][Y]==0||m[X-1][Y]==2||(m[X-1][Y]>=10&&m[X-1][Y]<=31)) tX=Er=0; //跳跃次数清零 
        if(X<=K) tX=Er=0,X=K; if(X>=K+28) X=K+28,Kb=1; //高度上下限
        if(m[X][Y]==7) m[X-1][Y]=m[X-2][Y]=1,tX+=8;
        if(m[X][Y]!=1&&m[X][Y]!=8&&m[X][Y]!=9) Blood--,m[X][Y]=1,system("color 4F"),Sleep(50),system("color 0F"),Map(3);
        if(Blood<=0) Win=-1;
        SetPos(X-K,Y),Color(1),cout<<"●";
    }
    void Map(int a)
    {
        SetPos(0,2);cout<<"Blood: "<<Blood<<"  ";
        SetPos(1,2);cout<<"Score: "<<Score<<"  ";
        if(a==3) system("cls");
        for(int i=K+28;i>=K;i--)for(int j=1;j<=20;j++) Cout(i,j,a);
        for(int i=K+33;i>K+28;i--)for(int j=1;j<=20;j++) Cout(i,j,4);
        if(a!=3) Wo();
    }
    void CircleBomb(int x,int y,int s,int ms)
    {
        if(s==ms) return;
        for(int i=x-s;i<=x+s;i++)
        for(int j=y-s;j<=y+s;j++)
        {
            float k=(i-x)*(i-x)+(j-y)*(j-y)-s*s;
            if(k<=s&&k>=-s&&j>0&&j<=20&&m[i+K][j]!=2&&m[i+K][j]!=9) m[i+K][j]=3;
        }Zb++;
        B[Zb].xx=x,B[Zb].yy=y,B[Zb].Zhong=1,B[Zb].rr=s+1,B[Zb].mr=ms;
        Sleep(30);
    }
    void LineBomb(int i,int j)
    {
        for(int k=0;j+k<=20;k++) if(m[i+K][j+k]!=2&&m[i+K][j+k]!=9) m[i+K][j+k]=3;
        for(int k=0;j+k<=20;k++) if(m[i+K+1][j+k]!=2&&m[i+K+1][j+k]!=9) m[i+K+1][j+k]=3;
        for(int k=0;j-k>0;k++) if(m[i+K][j-k]!=2&&m[i+K][j-k]!=9) m[i+K][j-k]=3;
        for(int k=0;j-k>0;k++) if(m[i+K+1][j-k]!=2&&m[i+K+1][j-k]!=9) m[i+K+1][j-k]=3;
    }
    void ZuanBomb(int i,int j)
    {
        int k;
        for(k=0;m[i+K+k][j]!=2&&k<=7;k++) if(m[i+K+k][j]!=9) m[i+K+k][j]=3;
        int k1=rand()%2+2;Zb++;
        B[Zb].xx=i+k,B[Zb].yy=j,B[Zb].Zhong=1,B[Zb].rr=0,B[Zb].mr=k1*3/2;
    }
    void TrigleBomb(int i,int j,int r,int mr)
    {
        if(r==mr) return;
        if(r==1) m[i+K][j]=3,i++;
        for(int k=max(0,j-r);k<=min(20,j+r);k++) if(m[i+K][k]!=2&&m[i+K][k]!=9) m[i+K][k]=3;
        Zb++;B[Zb].xx=i+1,B[Zb].yy=j,B[Zb].Zhong=5,B[Zb].rr=r+1,B[Zb].mr=mr;
    }
    void GunBomb(int i,int j,int r,int mr)
    {
        if(mr<=0) return;Zb++;
        B[Zb].xx=i,B[Zb].yy=j+2,B[Zb].Zhong=6,B[Zb].rr=r,B[Zb].mr=mr-1;Zb++;
        B[Zb].xx=i,B[Zb].yy=j,B[Zb].Zhong=1,B[Zb].rr=r-1,B[Zb].mr=r;
    }
    void GunBomb2(int i,int j,int r,int mr)
    {
        if(mr<=0) return;Zb++;
        B[Zb].xx=i,B[Zb].yy=j-2,B[Zb].Zhong=7,B[Zb].rr=r,B[Zb].mr=mr-1;Zb++;
        B[Zb].xx=i,B[Zb].yy=j,B[Zb].Zhong=1,B[Zb].rr=r-1,B[Zb].mr=r;
    }
    void ThreeBomb(int x,int y,int s,int ms)
    {
        for(int i=1;i<=3;i++)
        {
            int Xx=rand()%(2*s+1)-s,Yy=rand()%(2*s+1)-s; Zb++;
            B[Zb].xx=Xx+x,B[Zb].yy=Yy+y,B[Zb].Zhong=1,B[Zb].rr=0,B[Zb].mr=ms+rand()%3-1;
        }
    }
    void Sheng(int a)
    {
        K++;
        for(int i=1;i<=20;i++)
        {
            int R=rand()%max(80-(K/10),30);int Rr=rand()%200;
            if(R<=3) m[K+28][i]=2;
            else if(R<=6) m[K+28][i]=7;
            else if(R<=9) m[K+28][i]=8;
            if(Rr==0) m[K+28][i]=9;
        }
        if(a!=1) system("cls"),Map(0);
    }
    void Jiao()
    {
        SetPos(0,2);Color(1),cout<<"●",Color(7),cout<<"   ■ ",Color(8),cout<<"   ■ ",Color(4),cout<<"   ●    ",Color(9),cout<<"~ ",Color(0),cout<<"   ",Color(10),cout<<"~ ",Color(3),cout<<"   ◆";
        SetPos(2,2);Color(0),cout<<"你  泥土  石块  炸弹  岩浆  水  宝石";
        SetPos(4,1),cout<<"  ↑           空格放炸弹..."; 
        SetPos(5,1),cout<<"←  →移动 ";
        SetPos(6,1),cout<<"  ↓           可二段跳。";
        SetPos(8,1),cout<<"炸弹种类随机,计时3秒爆炸。";
        SetPos(10,1),cout<<"(一共有7种炸弹,有几率组合一起爆炸)";
        SetPos(12,1),cout<<"岩浆和水有几率向左右扩散...";
        SetPos(14,1),cout<<"它们相融会产生石块。";
        SetPos(16,1),cout<<"岩浆和爆炸波会使你减血...";
        SetPos(18,1),cout<<"岩浆还会使你上跳,宝石可以加血。";
        SetPos(20,1),cout<<"画面每隔一段时间会下降...";
        SetPos(22,1),cout<<"当你抵达画面底部时,画面会随你一起下降...";
        SetPos(24,1),cout<<"当你被抵在画面顶部时,会持续减血。";
        SetPos(26,1),cout<<"每隔一段时间分数会增加...",Color(5),cout<<"500分即可通关!";
        SetPos(28,1);Color(1);cout<<"按 y 开始游戏!";
        char tt;while(tt!='y') tt=_getch();
    }
    void Start()
    {
        Color(5);
        SetPos(2,3);Color(7),cout<<" ■        ",Color(5),cout<<"掘",Color(7),cout<<"    ■■■■ ";
        SetPos(3,3);Color(7),cout<<" ■■     ",Color(5),cout<<" ↓",Color(7),cout<<"    ■■■■ ";
        SetPos(4,3);Color(7),cout<<" ■■■■ ",Color(5),cout<<" ↓",Color(7),cout<<"  ■■■■■ ";
        SetPos(5,3);Color(7),cout<<" ■■■■■",Color(5),cout<<"↓",Color(7),cout<<"  ■■■■■ ";
        SetPos(6,3);Color(7),cout<<" ■■■■■  ■■■",Color(5),cout<<"地",Color(7),cout<<"■■ ";
        SetPos(7,3);Color(7),cout<<" ■■■■■■■■■■■■ ";Color(5);
        SetPos(10,3);cout<<"             ■■■     ■    ";
        SetPos(11,3);cout<<"             ■  ■    ■     ";
        SetPos(12,3);Color(8),cout<<"  ■■■ ",Color(5),cout<<"    ■■■  ■    ■ ";
        SetPos(13,3);Color(8),cout<<"  ■",Color(5),cout<<"矿",Color(8),cout<<"■ ",Color(5),cout<<"    ■  ■ ■■■■■";
        SetPos(14,3);Color(8),cout<<"  ■■■ ",Color(5),cout<<"    ■  ■           ";
        SetPos(15,3);cout<<"             ■■■  ■■■■ ";
        SetPos(16,3);cout<<"             ■  ■  ■    ■ ";
        SetPos(17,3);cout<<"             ■  ■  ■    ■ ";
        SetPos(18,3);cout<<"           ■■  ■  ■■■■ ";
        SetPos(22,2);Color(1);cout<<"按 y 确定!";
        SetPos(22,10);Color(9);cout<<"    开始游戏!    ";
        SetPos(24,10);Color(0);cout<<"    操作攻略!    ";
        SetPos(27,1);Color(3);cout<<"注意!这里 绝对不能是拼音输入法!";
        SetPos(28,5);Color(3);cout<<"↓";Color(0);
        char tt;int Ee=0;
        while(tt!='y')
        {
            tt=_getch();
            if(tt==72&&Ee!=0) Ee--;
            if(tt==80&&Ee!=2) Ee++;
            SetPos(22,10);if(Ee==0) Color(9);else Color(0);cout<<"    开始游戏!    ";
            SetPos(24,10);if(Ee==1) Color(9);else Color(0);cout<<"    操作攻略!    ";
        }system("color 0F");system("cls");Color(0);
        if(Ee==1) Jiao();
    }
    int main()
    {
        system("mode con cols=42 lines=31");
        CONSOLE_CURSOR_INFO cursor_info={1,0};
        SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE),&cursor_info);
        srand((unsigned)time(NULL));
        Start();
        St:system("cls");
        K=-5,T=Win=Score=0;X=Y=2;Blood=20;
        memset(m,0,sizeof(m));memset(B,0,sizeof(B));
        for(int i=5;i<=15;i++) for(int j=1;j<=20;j++) m[i][j]=1;
        for(int i=1;i<=10;i++) Sheng(1);
        Map(0);
        while(Win==0)
        {
            T++;Kb=0;if(Score>=500) Win=1;
            if(GetAsyncKeyState(VK_UP)&0x8000&&tT==0&&Er<2) tT++,tX+=4,Er++;
            if((GetAsyncKeyState(VK_UP)&0x8000)?0:1) tT=0;
            if(GetAsyncKeyState(VK_LEFT)&0x8000&&Y>1&&(m[X][Y-1]==1||m[X][Y-1]==7||m[X][Y-1]==8||m[X][Y-1]==9)&&(tY==0||tY>=2)) SetPos(X-K,Y),cout<<"  ",Y--;
            if(GetAsyncKeyState(VK_RIGHT)&0x8000&&Y<20&&(m[X][Y+1]==1||m[X][Y+1]==7||m[X][Y+1]==8||m[X][Y+1]==9)&&(tY2==0||tY2>=2)) SetPos(X-K,Y),cout<<"  ",Y++;
            if((GetAsyncKeyState(VK_LEFT)&0x8000)?0:1) tY=0;if((GetAsyncKeyState(VK_RIGHT)&0x8000)?0:1) tY2=0;
            if((GetAsyncKeyState(VK_LEFT)&0x8000)?1:0) tY++;if((GetAsyncKeyState(VK_RIGHT)&0x8000)?1:0) tY2++;
            if(kbhit()) {char e=_getch();if(e==' '&&m[X-1][Y]!=0&&m[X-1][Y]!=2&&(m[X+1][Y]<=10||m[X+1][Y]>=31)&&Kb==0) m[X][Y]=10,X--;}
            int zb=Zb;
            for(int i=zb-10;i<=zb;i++)
            {
                if(B[i].Zhong==1) CircleBomb(B[i].xx,B[i].yy,B[i].rr,B[i].mr),B[i].Zhong=0;
                if(B[i].Zhong==2) LineBomb(B[i].xx,B[i].yy),B[i].Zhong=0;
                if(B[i].Zhong==3) ThreeBomb(B[i].xx,B[i].yy,B[i].rr,B[i].mr),B[i].Zhong=0;
                if(B[i].Zhong==4) ZuanBomb(B[i].xx,B[i].yy),B[i].Zhong=0;
                if(B[i].Zhong==5) TrigleBomb(B[i].xx,B[i].yy,B[i].rr,B[i].mr),B[i].Zhong=0;
                if(B[i].Zhong==6) GunBomb(B[i].xx,B[i].yy,B[i].rr,B[i].mr),B[i].Zhong=0;
                if(B[i].Zhong==7) GunBomb2(B[i].xx,B[i].yy,B[i].rr,B[i].mr),B[i].Zhong=0;
            }
            Map(1);Sleep(40);
            if(T%max(10,40-Score/16)==0||Kb>=1) Sheng(0);
            if(T%20==0) Score++;
        }
        if(Win!=0)
        {
            if(Win>0) {system("color 6E"),Color(3);SetPos(0,2);cout<<"You! Win!!!",Sleep(1000);}
            if(Win<0) {system("color 7F"),Color(4);SetPos(0,2);cout<<"You! Die!!!",Sleep(1000);}
            SetPos(1,2);cout<<"Please point 'y' to Play AGain.";
            A:char e=_getch();if(e!='y') goto A;goto St;
        }
    }
    
  • 通过的题目

  • 最近活动

  • 最近编写的题解

    This person is lazy and didn't write any solutions.

题目标签

普及-
46
模拟
32
语言入门
29
其他
13
字符串
12
循环结构
12
分支结构
11
顺序结构
11
搜索
10
计算几何
9
排序
9
枚举
6
普及/提高-
6
初级班期中考
5
入门
4
数学
4
结构体
4
while循环
3
素数判断
2
质数
2