• 个人简介

    给个赞 https://oiclass.com/user/11932

    wc是谁那么闲把我题解全👎了一遍,恶意👎题解氼价厅司符亩

    好玩的(两大网页经典游戏)

    网页植物大战僵尸

    网页我的世界

    steam

    很多人不知道像这种:

    #include<bits/stdc++.h>
    using namespace std;
    stack<int> s[80001];
    int main(){
    	int a,b;
    	cin>>a>>b;
    	cout<<a+b;
    }
    
    彩色的代码块怎么打,我来教:

    首先看到点击块级代码会出现:

    
    //```language
    //```
    
    
    

    把language改为c++.line-numbers:

    
    //```c++.line-numbers
    
    //```
    
    

    就行了

    连点器(非本人原创,只是稍微改进,加上可以重新输入速度)

    #include<iostream>
    #include<stdio.h>
    #include<windows.h>
    using namespace std;
    long double a,b=1000;
    int x,y;
    bool n,m;
    int main()
    { 
    	POINT p;
    	system("color 0b");
    	system("mode con cols=20 lines=8");
    	cout<<"鼠标中键开始 Alt停止"<<endl;
    	cout<<"右边Ctrl锁定 Esc解锁"<<endl; 
    	cout<<"速度(一秒钟点几次)"<<endl<<endl;
    	cout<<"输入: ";
    	cin>>a;
    	bool gg=0;
        while(1)
        {
            if(GetAsyncKeyState(VK_MBUTTON)) m=1;
            if(GetAsyncKeyState(VK_MENU)) {
            	m=0;
            	if(gg==0){
            		cout<<"是否重新输入一遍?\n是输入y,否输入n"<<endl; 
            		char sb;
            		cin>>sb;
            		if(sb=='y')cin>>a;
            		else{
            			cout<<"是否不再提醒再次输入?\n是输入y,否输入n"<<endl;
    					cin>>sb;
    					if(sb=='y')gg=1; 
    				}
    			}
            	
    		}
            if(m)
            {
    	        mouse_event(MOUSEEVENTF_LEFTDOWN|MOUSEEVENTF_LEFTUP,0,0,0,0);
    	        Sleep(b/a);
    		}
            
            if(GetAsyncKeyState(VK_RCONTROL)) n=1;
    		if(GetAsyncKeyState(VK_ESCAPE)) n=0;
    		if(!n)
    		{
    			if (GetCursorPos(&p))
    			{
    				x=p.x;
    				y=p.y;
    			}
    		}
    		if(n)
    		{
    			SetCursorPos(x,y);
    		}
        }
        return 0;
    }
    

    非本人游戏,淘金淘到的

    #include<windows.h>
    #include<bits/stdc++.h>
    using namespace std;
    
    // 控制台颜色枚举
    enum ConsoleColor {
        BLACK = 0, BLUE = 1, GREEN = 2, CYAN = 3, 
        RED = 4, MAGENTA = 5, BROWN = 6, LIGHTGRAY = 7,
        DARKGRAY = 8, LIGHTBLUE = 9, LIGHTGREEN = 10, LIGHTCYAN = 11,
        LIGHTRED = 12, LIGHTMAGENTA = 13, YELLOW = 14, WHITE = 15
    };
    
    // 道具类型枚举
    enum ItemType {
        MAGNIFIER = 0, HANDCUFFS = 1, BONE_BLADE = 2, CHEAT = 3, DRINK = 4
    };
    
    // 玩家类
    class Player {
    public:
        string name;
        int health;
        int items[5];
        bool hasCuffEffect;
        double money;
        
        Player(string n, int h) : name(n), health(h), hasCuffEffect(false), money(0) {
            for(int i = 0; i < 5; i++) items[i] = 0;
        }
        
        void useItem(int itemType) {
            if(items[itemType] > 0) {
                items[itemType]--;
            }
        }
        
        bool canUseItem(int itemType) {
            return items[itemType] > 0;
        }
    };
    
    // 游戏类
    class Game {
    private:
        Player* player1;
        Player* player2;
        int bullets[10];  // 1实弹 2空弹
        int bulletCount;
        int currentBullet;
        int damageMultiplier;
        bool isSinglePlayer;
        bool nextBulletKnown;
        bool isNextBulletReal;
        bool shouldRepeatTurn;  // 新增标志,记录是否需要重复回合
        
    public:
        Game(bool singlePlayer) : isSinglePlayer(singlePlayer), damageMultiplier(1), 
                                  nextBulletKnown(false), isNextBulletReal(false),
                                  shouldRepeatTurn(false) {
            if(singlePlayer) {
                player1 = new Player("玩家", 5);
                player2 = new Player("Puster", 5);
            } else {
                player1 = new Player("玩家A", 4);
                player2 = new Player("玩家B", 4);
            }
            bulletCount = 0;
            currentBullet = 0;
        }
        
        ~Game() {
            delete player1;
            delete player2;
        }
        
        // 设置控制台颜色
        void setColor(ConsoleColor textColor, ConsoleColor backgroundColor = BLACK) {
            HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
            SetConsoleTextAttribute(hConsole, (WORD)((backgroundColor << 4) | textColor));
        }
        
        // 重置颜色
        void resetColor() {
            setColor(LIGHTGRAY, BLACK);
        }
        
        // 随机数生成
        int rand(int x, int y) {
            return std::rand() % (y - x + 1) + x;
        }
        
        // 等待动画
        void wait() {
            for(int i = 1; i <= 3; i++) {
                Sleep(500);
                printf(".");
            }
            Sleep(500);
        }
        
        // 设置控制台窗口为紧凑模式
        void setCompactConsoleWindow() {
            // 获取控制台窗口句柄
            HWND consoleWindow = GetConsoleWindow();
            
            // 设置窗口样式,移除滚动条和最大化按钮
            LONG style = GetWindowLong(consoleWindow, GWL_STYLE);
            style &= ~(WS_MAXIMIZEBOX | WS_THICKFRAME);
            SetWindowLong(consoleWindow, GWL_STYLE, style);
            
            // 获取当前字体信息以计算字符尺寸
            CONSOLE_FONT_INFOEX fontInfo;
            fontInfo.cbSize = sizeof(fontInfo);
            HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);
            GetCurrentConsoleFontEx(hOut, FALSE, &fontInfo);
            
            // 计算窗口需要的尺寸(基于80x25的标准控制台)
            int charWidth = fontInfo.dwFontSize.X;
            int charHeight = fontInfo.dwFontSize.Y;
            
            // 窗口边框和标题栏的额外像素
            RECT rect;
            GetWindowRect(consoleWindow, &rect);
            int borderWidth = rect.right - rect.left - 80 * charWidth;
            int titleHeight = rect.bottom - rect.top - 25 * charHeight;
            
            // 设置缓冲区大小与窗口大小一致
            COORD coord = {80, 25}; // 80列,25行
            SetConsoleScreenBufferSize(hOut, coord);
            
            // 调整窗口大小以适应内容
            SetWindowPos(consoleWindow, NULL, rect.left, rect.top, 
                        80 * charWidth + borderWidth, 25 * charHeight + titleHeight, 
                        SWP_SHOWWINDOW);
        }
        
        // 调整窗口大小以适应内容
        void resizeConsoleToContent() {
            // 获取当前控制台屏幕缓冲区信息
            CONSOLE_SCREEN_BUFFER_INFO csbi;
            HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);
            GetConsoleScreenBufferInfo(hOut, &csbi);
            
            // 获取当前窗口信息
            SMALL_RECT windowRect = csbi.srWindow;
            int windowWidth = windowRect.Right - windowRect.Left + 1;
            int windowHeight = windowRect.Bottom - windowRect.Top + 1;
            
            // 获取当前字体信息
            CONSOLE_FONT_INFOEX fontInfo;
            fontInfo.cbSize = sizeof(fontInfo);
            GetCurrentConsoleFontEx(hOut, FALSE, &fontInfo);
            
            // 获取控制台窗口句柄
            HWND consoleWindow = GetConsoleWindow();
            
            // 计算窗口需要的尺寸
            int charWidth = fontInfo.dwFontSize.X;
            int charHeight = fontInfo.dwFontSize.Y;
            
            // 窗口边框和标题栏的额外像素
            RECT rect;
            GetWindowRect(consoleWindow, &rect);
            int borderWidth = rect.right - rect.left - windowWidth * charWidth;
            int titleHeight = rect.bottom - rect.top - windowHeight * charHeight;
            
            // 确保窗口高度至少为30行,适应新增内容
            windowHeight = max(windowHeight, 30);
            
            // 调整窗口大小以适应内容
            SetWindowPos(consoleWindow, NULL, rect.left, rect.top, 
                        windowWidth * charWidth + borderWidth, 
                        windowHeight * charHeight + titleHeight, 
                        SWP_SHOWWINDOW);
        }
        
        // 初始化子弹
        void initBullets() {
            int realBullets = rand(1, 4);
            int emptyBullets = rand(1, 4);
            bulletCount = realBullets + emptyBullets;
            currentBullet = 0;
            
            printf("子弹配置: %d发实弹, %d发空弹\n", realBullets, emptyBullets);
            
            // 随机排列子弹
            vector<int> temp;
            for(int i = 0; i < realBullets; i++) temp.push_back(1);
            for(int i = 0; i < emptyBullets; i++) temp.push_back(2);
            
            random_shuffle(temp.begin(), temp.end());
            for(int i = 0; i < bulletCount; i++) {
                bullets[i] = temp[i];
            }
            
            // 为玩家分配道具
            distributeItems(player1, 4);
            if(!isSinglePlayer) distributeItems(player2, 4);
            else distributeItems(player2, 2);
            
            system("pause");
            system("cls");
            resizeConsoleToContent(); // 调整窗口大小
        }
        
        // 分配道具
        void distributeItems(Player* player, int count) {
            string itemNames[] = {"放大镜", "手铐", "骨刃", "激素针?", "饮料"};
            int maxItems = isSinglePlayer ? 8 : 4;
            
            count = min(count, maxItems - getTotalItems(player));
            printf("%s获得了%d个道具:\n", player->name.c_str(), count);
            
            for(int i = 0; i < count; i++) {
                int itemType = rand(0, 4);
                player->items[itemType]++;
                cout << itemNames[itemType];
                if(i != count - 1) printf(",");
            }
            printf("\n");
        }
        
        // 获取玩家道具总数
        int getTotalItems(Player* player) {
            int sum = 0;
            for(int i = 0; i < 5; i++) sum += player->items[i];
            return sum;
        }
        
        // 显示游戏状态
        void showGameState() {
            setColor(RED);
            printf("%s的生命:%d/%d\n%s生命:%d/%d\n", 
                   player1->name.c_str(), player1->health, (isSinglePlayer ? 5 : 4),
                   player2->name.c_str(), player2->health, (isSinglePlayer ? 5 : 4));
            resetColor();
            
            setColor(BLUE);
            // 显示剩余子弹信息
            int remainingBullets = max(0, bulletCount - currentBullet);
            int remainingReal = countRealBullets();
            int remainingEmpty = remainingBullets - remainingReal;
            
            printf("剩余子弹: %d发 (实弹: %d, 空弹: %d)\n", 
                   remainingBullets, remainingReal, remainingEmpty);
            resetColor();
            
            setColor(GREEN);
            printf("%s现在拥有的道具:\n", player1->name.c_str());
            printItems(player1);
            resetColor();
            
            if(isSinglePlayer) {
                setColor(MAGENTA);
                printf("%s现在拥有的道具:\n", player2->name.c_str());
                printItems(player2);
                resetColor();
            }
        }
        
        // 显示道具列表
        void printItems(Player* player) {
            string itemNames[] = {"放大镜", "手铐", "骨刃", "激素针?", "饮料"};
            for(int i = 0; i < 5; i++) {
                cout << itemNames[i] << ":" << player->items[i] << "个";
                if(i != 4) printf(",");
            }
            printf("\n");
        }
        
        // 玩家回合
        void playerTurn(Player* attacker, Player* defender) {
            showGameState();
            
            setColor(YELLOW);
            printf("--------------------现在是%s的回合--------------------\n", attacker->name.c_str());
            resetColor();
            
            bool hasShot = false;  // 记录是否已开枪
            
            while(!hasShot) {
                setColor(CYAN);
                printf("%s要\n1.向%s开枪\n2.向自己开枪\n", attacker->name.c_str(), defender->name.c_str());
                for(int i = 0; i <= 4; i++) {
                    printf("%d.使用", i + 3);
                    string itemNames[] = {"放大镜", "手铐", "骨刃", "激素针?", "饮料"};
                    cout << itemNames[i] << '\n';
                }
                resetColor();
                
                int choice;
                // 清空输入缓冲区,避免残留输入导致问题
                cin.clear();
                cin.ignore(numeric_limits<streamsize>::max(), '\n');
                
                if(!(cin >> choice)) {
                    setColor(RED);
                    printf("输入不合法,请输入数字选项\n");
                    resetColor();
                    cin.clear();
                    cin.ignore(numeric_limits<streamsize>::max(), '\n');
                    Sleep(1000);
                    system("cls");
                    resizeConsoleToContent();
                    showGameState();
                    continue;
                }
                
                if(choice >= 1 && choice <= 7) {
                    if(choice == 1 || choice == 2) {  // 开枪选项
                        hasShot = true;  // 标记已开枪
                        bool isSelfShoot = (choice == 2);
                        shouldRepeatTurn = shoot(attacker, defender, isSelfShoot);
                    } else {  // 使用道具
                        processPlayerChoice(attacker, defender, choice);
                        system("cls");
                        resizeConsoleToContent();
                        showGameState();  // 显示更新后的游戏状态,继续回合
                    }
                } else {
                    setColor(RED);
                    printf("输入不合法,请输入1-7之间的数字\n");
                    resetColor();
                    Sleep(1000);
                    system("cls");
                    resizeConsoleToContent();
                    showGameState();
                }
            }
            
            Sleep(1000);
            system("cls");
            resizeConsoleToContent(); // 调整窗口大小
        }
        
        // 处理玩家选择
        void processPlayerChoice(Player* attacker, Player* defender, int choice) {
            string itemNames[] = {"放大镜", "手铐", "骨刃", "激素针?", "饮料"};
            
            int itemType = choice - 3;
            
            if(!attacker->canUseItem(itemType)) {
                setColor(RED);
                printf("%s现在没有%s\n", attacker->name.c_str(), itemNames[itemType].c_str());
                resetColor();
                Sleep(1000);
                return;
            }
            
            useItem(attacker, defender, itemType);
        }
        
        // 使用道具
        void useItem(Player* attacker, Player* defender, int itemType) {
            string itemNames[] = {"放大镜", "手铐", "骨刃", "激素针?", "饮料"};
            attacker->useItem(itemType);
            
            switch(itemType) {
                case MAGNIFIER: // 放大镜
                    setColor(YELLOW);
                    printf("%s使用了放大镜\n", attacker->name.c_str());
                    resetColor();
                    wait();
                    
                    printf("\n%s看到了", attacker->name.c_str());
                    if(bullets[currentBullet] == 1) {
                        setColor(RED);
                        printf("实弹\n");
                        resetColor();
                        attacker->money += 2500.0;
                        nextBulletKnown = true;
                        isNextBulletReal = true;
                    } else {
                        setColor(GREEN);
                        printf("空弹\n");
                        resetColor();
                        nextBulletKnown = true;
                        isNextBulletReal = false;
                    }
                    break;
                    
                case HANDCUFFS: // 手铐
                    if(!attacker->hasCuffEffect) {
                        attacker->hasCuffEffect = true;
                        setColor(YELLOW);
                        printf("%s使用了手铐\n", attacker->name.c_str());
                        printf("%s获得了连开两枪的机会\n", attacker->name.c_str());
                        resetColor();
                    } else {
                        setColor(RED);
                        printf("%s已经用过手铐了\n", attacker->name.c_str());
                        resetColor();
                    }
                    break;
                    
                case BONE_BLADE: // 骨刃
                    if(damageMultiplier == 1) {
                        damageMultiplier = 2;
                        setColor(YELLOW);
                        printf("%s使用了骨刃\n", attacker->name.c_str());
                        printf("若下一发为实弹则伤害+1\n");
                        resetColor();
                        attacker->money += 500.0;
                    } else {
                        setColor(RED);
                        printf("%s已经用过骨刃了\n", attacker->name.c_str());
                        resetColor();
                    }
                    break;
                    
                case CHEAT: // 激素针?
                    if(attacker->health < (isSinglePlayer ? 5 : 4)) {
                        attacker->health++;
                        setColor(YELLOW);
                        printf("%s使用了激素针?\n", attacker->name.c_str());
                        printf("%s回复了一点生命\n", attacker->name.c_str());
                        resetColor();
                        attacker->money += 500.0;
                    } else {
                        setColor(RED);
                        printf("%s现在不需要开挂\n", attacker->name.c_str());
                        resetColor();
                    }
                    break;
                    
                case DRINK: // 饮料
                    setColor(YELLOW);
                    printf("%s使用了饮料\n", attacker->name.c_str());
                    resetColor();
                    wait();
                    
                    printf("\n");
                    printf("%s退了一发", attacker->name.c_str()); 
                    if(bullets[currentBullet] == 2) {
                        setColor(GREEN);
                        printf("空弹");
                        resetColor();
                    } else {
                        setColor(RED);
                        printf("实弹");
                        resetColor();
                        attacker->money += 500.0;
                    }
                    
                    // 移除当前子弹
                    for(int i = currentBullet; i < bulletCount - 1; i++) {
                        bullets[i] = bullets[i + 1];
                    }
                    bulletCount--;
                    
                    // 重置状态
                    nextBulletKnown = false;
                    damageMultiplier = 1;
                    break;
            }
            
            Sleep(1000);
        }
        
        // 开枪 - 修改为返回是否应该重复回合
        bool shoot(Player* attacker, Player* target, bool isSelfShoot) {
            bool shouldRepeat = false;  // 默认不重复回合
            
            if(isSelfShoot) {
                setColor(CYAN);
                printf("%s决定向自己开枪", attacker->name.c_str());
                resetColor();
            } else {
                setColor(CYAN);
                printf("%s决定向%s开枪", attacker->name.c_str(), target->name.c_str());
                resetColor();
            }
            
            wait();
            
            if(bullets[currentBullet] == 2) { // 空弹
                setColor(GREEN);
                printf("是空弹\n");
                resetColor();
                attacker->money += (double)(2000.0 * damageMultiplier * 
                                  (1 + (double)countRealBullets() / (double)bulletCount));
                currentBullet++;
                damageMultiplier = 1;
                nextBulletKnown = false;
                
                if(attacker->hasCuffEffect) {
                    attacker->hasCuffEffect = false;
                    setColor(YELLOW);
                    printf("因为%s使用了手铐,所以可以再来一次\n", attacker->name.c_str());
                    resetColor();
                    Sleep(500);
                }
                
                // 如果是向自己开枪且为空弹,则设置重复回合标志
                if(isSelfShoot) {
                    shouldRepeat = true;
                    setColor(YELLOW);
                    printf("因为向自己开枪是空弹,%s将再进行一回合\n", attacker->name.c_str());
                    resetColor();
                    Sleep(1500);
                }
            } else { // 实弹
                setColor(RED);
                printf("是实弹\n");
                resetColor();
                attacker->money += (double)(5000.0 * damageMultiplier * 
                                  (1 + (double)countEmptyBullets() / (double)bulletCount));
                currentBullet++;
                target->health -= damageMultiplier;
                damageMultiplier = 1;
                nextBulletKnown = false;
                
                Sleep(500);
                
                // 仅当目标生命值确实<=0时才检查游戏结束
                if(target->health <= 0) {
                    if(checkGameOver()) return false;
                }
                
                if(attacker->hasCuffEffect) {
                    attacker->hasCuffEffect = false;
                    attacker->money += 1000.0;
                    setColor(YELLOW);
                    printf("因为%s使用了手铐,所以可以再来一次\n", attacker->name.c_str());
                    resetColor();
                    Sleep(500);
                }
            }
            
            Sleep(1000);
            return shouldRepeat;
        }
        
        // 计算剩余实弹数
        int countRealBullets() {
            int count = 0;
            for(int i = currentBullet; i < bulletCount; i++) {
                if(bullets[i] == 1) count++;
            }
            return count;
        }
        
        // 计算剩余空弹数
        int countEmptyBullets() {
            return max(0, bulletCount - currentBullet - countRealBullets());
        }
        
        // AI回合
        void aiTurn() {
            showGameState();
            
            setColor(YELLOW);
            printf("--------------------现在是%s的回合--------------------\n", player2->name.c_str());
            resetColor();
            Sleep(1500);
            
            bool hasShot = false;
            bool shouldRepeat = false;
            
            while(!hasShot) {
                // AI决策逻辑
                int choice = decideAIAction();
                
                if(choice == 1 || choice == 2) {  // 开枪选项
                    hasShot = true;
                    bool isSelfShoot = (choice == 2);
                    shouldRepeat = shoot(player2, player1, isSelfShoot);
                } else {  // 使用道具
                    processPlayerChoice(player2, player1, choice);
                    system("cls");
                    resizeConsoleToContent();
                    showGameState();
                    
                    // 让AI决定是否继续使用道具或开枪
                    Sleep(1000);
                    if(decideContinueUsingItems()) {
                        setColor(YELLOW);
                        printf("%s决定继续行动...\n", player2->name.c_str());
                        resetColor();
                        Sleep(1000);
                    } else {
                        setColor(YELLOW);
                        printf("%s决定开枪...\n", player2->name.c_str());
                        resetColor();
                        Sleep(1000);
                        choice = 1;  // 默认向玩家开枪
                        hasShot = true;
                        shouldRepeat = shoot(player2, player1, false);
                    }
                }
            }
            
            shouldRepeatTurn = shouldRepeat;  // 设置全局标志
            Sleep(1000);
            system("cls");
            resizeConsoleToContent(); // 调整窗口大小
        }
        
        // AI决策
        int decideAIAction() {
            // 检查是否有高优先级行动
            if(player2->health < 3 && player2->canUseItem(CHEAT)) {
                return CHEAT + 3; // 使用激素针?
            }
            
            if(nextBulletKnown && isNextBulletReal && player2->canUseItem(BONE_BLADE)) {
                return BONE_BLADE + 3; // 使用骨刃
            }
            
            if(nextBulletKnown && !isNextBulletReal && player2->canUseItem(DRINK)) {
                return DRINK + 3; // 使用饮料
            }
            
            if(!nextBulletKnown && player2->canUseItem(MAGNIFIER)) {
                return MAGNIFIER + 3; // 使用放大镜
            }
            
            if(player2->canUseItem(HANDCUFFS)) {
                return HANDCUFFS + 3; // 使用手铐
            }
            
            // 如果AI生命值较低,有30%概率选择向自己开枪
            if(player2->health <= 2 && rand(1, 10) <= 3) {
                return 2; // 向自己开枪
            }
            
            // 默认向玩家开枪
            return 1;
        }
        
        // AI决定是否继续使用道具
        bool decideContinueUsingItems() {
            // 检查是否有任何可用的道具
            for(int i = 0; i < 5; i++) {
                if(player2->canUseItem(i)) {
                    // 70%的概率继续使用道具
                    return rand(1, 10) <= 7;
                }
            }
            return false;
        }
        
        // 检查游戏是否结束
        bool checkGameOver() {
            if(player1->health <= 0) {
                setColor(RED);
                printf("%s输了\n", player1->name.c_str());
                if(isSinglePlayer) {
                    printf("%s赢了\n", player2->name.c_str());
                } else {
                    printf("%s赢了\n", player2->name.c_str());
                }
                printf("%s获得了奖金$%.2lf\n", player2->name.c_str(), player2->money);
                resetColor();
                system("pause");
                return true;
            } else if(player2->health <= 0) {
                setColor(GREEN);
                printf("%s赢了\n", player1->name.c_str());
                printf("%s获得了奖金$%.2lf\n", player1->name.c_str(), player1->money);
                resetColor();
                system("pause");
                return true;
            }
            return false;
        }
        
        // 游戏主循环
        void run() {
            setCompactConsoleWindow(); // 初始化窗口大小
            
            if(isSinglePlayer) showSinglePlayerIntro();
            else showMultiPlayerIntro();
            
            while(true) {
                if(currentBullet >= bulletCount || bulletCount == 0) {
                    initBullets();
                }
                
                // 玩家1回合
                do {
                    shouldRepeatTurn = false; // 重置标志
                    playerTurn(player1, player2);
                } while(shouldRepeatTurn && !checkGameOver());
                
                if(checkGameOver()) break;
                
                if(isSinglePlayer) {
                    // AI回合
                    do {
                        shouldRepeatTurn = false; // 重置标志
                        aiTurn();
                    } while(shouldRepeatTurn && !checkGameOver());
                    
                    if(checkGameOver()) break;
                } else {
                    // 玩家2回合
                    do {
                        shouldRepeatTurn = false; // 重置标志
                        playerTurn(player2, player1);
                    } while(shouldRepeatTurn && !checkGameOver());
                    
                    if(checkGameOver()) break;
                }
            }
        }
        
        // 单人游戏介绍
        void showSinglePlayerIntro() {
            setColor(YELLOW);
            printf("<Puster>:...\n");
            printf("<Puster>:又来了...\n");
            resetColor();
            Sleep(1000);
            
            int x;
            while(true) {
                setColor(LIGHTCYAN);
                printf("<Puster>:准备好play了吗?胜者拿钱败者Die\n1.ok\n2.没问题\n");
                resetColor();
                cin >> x;
                if(x == 1 || x == 2) break;
                setColor(RED);
                printf("输入不合法\n");
                resetColor();
                Sleep(1000);
                system("cls");
                resizeConsoleToContent(); // 调整窗口大小
            }
            
            while(true) {
                setColor(LIGHTCYAN);
                printf("<Puster>:你清楚我们的规则吗?\n1.清楚\n2.不清楚\n");
                resetColor();
                cin >> x;
                if(x == 1 || x == 2) break;
                setColor(RED);
                printf("输入不合法\n");
                resetColor();
                Sleep(1000);
                system("cls");
                resizeConsoleToContent(); // 调整窗口大小
            }
            
            if(x == 2) {
                setColor(YELLOW);
                printf("<Puster>:......\n");
                printf("<Puster>:规则:\n");
                resetColor();
                setColor(LIGHTGREEN);
                printf("<Puster>:你和Puster都各有5点生命\n");
                printf("<Puster>:每一回合开始前,你将知道一共有几发实弹,几发空弹,同时双方都将获得4个道具作为补给(上限为8个)\n");
                printf("<Puster>:每一回合,你可以选择对自己开枪,对Puster开枪或者使用道具\n");
                printf("<Puster>:你可以在开枪前使用任意数量的道具\n");
                printf("<Puster>:一旦开枪,无论结果如何,回合结束\n");
                printf("<Puster>:如果向自己开枪且为空弹,你将再进行一回合\n");
                resetColor();
                setColor(LIGHTMAGENTA);
                printf("<Puster>:道具一览:\n");
                printf("<Puster>:    放大镜:可以知道下一发子弹是空弹还是实弹\n");
                printf("<Puster>:    手铐:增加一次本回合的行动次数\n");
                printf("<Puster>:    骨刃:若下一发子弹为实弹,则伤害+1\n");
                printf("<Puster>:    激素针?:可以回复1点体力\n");
                printf("<Puster>:    饮料:可以退一发子弹\n");
                resetColor();
                system("pause");
                system("cls");
                resizeConsoleToContent(); // 调整窗口大小
            }
            
            setColor(YELLOW);
            printf("<Puster>:ok\n<Puster>:游戏开始...\n");
            resetColor();
            Sleep(1145);
            system("cls");
            resizeConsoleToContent(); // 调整窗口大小
        }
        
        // 多人游戏介绍
        void showMultiPlayerIntro() {
            setColor(YELLOW);
            printf("欢迎来到双人模式!\n");
            printf("玩家A和玩家B将轮流进行游戏\n");
            printf("每位玩家可以在开枪前使用任意数量的道具\n");
            printf("如果向自己开枪且为空弹,将再进行一回合\n");
            resetColor();
            Sleep(1000);
            
            system("pause");
            system("cls");
            resizeConsoleToContent(); // 调整窗口大小
        }
    };
    
    int main() {
        srand(time(NULL));
        
        int mode;
        while(true) {
            printf("请选择游戏模式:\n1. 单人模式\n2. 双人模式\n");
            cin >> mode;
            if(mode == 1 || mode == 2) break;
            printf("输入不合法,请重新输入!\n");
        }
        
        Game game(mode == 1);
        game.run();
        
        return 0;
    }
    
    
    
  • 最近活动

  • Stat

  • Rating