问题标题: 有没有大佬帮我改改

0
0
已解决
陶欣怡
陶欣怡
资深守护
资深守护
#include <iostream>
#include <conio.h>
using namespace std;

int main() {
    int x = 0, y = 0, vx = 1, vy = 0, score = 0;
    int a = 0, d = 0, w = 0, s = 0;
    char ch;

    while (y <= 24) {
        if (_kbhit()) {
            ch = _getch();
            switch (ch) {
            case 'a':
                a = 1;
                break;
            case 'd':
                d = 1;
                break;
            case 'w':
                w = 1;
                break;
            case 's':
                s = 1;
                break;
            default:
                break;
            }
        }
        y++;
        if (y == 5 || y == 10 || y == 15 || y == 20) {
            score += y * 10;
        }
        if (a == 1) {
            x -= vx;
            a = 0;
        }
        if (d == 1) {
            x += vx;
            d = 0;
        }
        if (w == 1) {
            vy -= 1;
            w = 0;
        }
        if (s == 1) {
            vy += 1;
            s = 0;
        }
        if (x <= -5) {
            x = -5;
        }
        if (x >= 5) {
            x = 5;
        }
        if (vy >= 10) {
            vy = 10;
        }
        if (vy <= -10) {
            vy = -10;
        }
        system("cls");
        cout << "Score: " << score << endl;
        cout << "Player Position: (" << x << ", " << y << ")" << endl;
        cout << "Move: ";
        if (a == 0 && d == 0 && w == 0 && s == 0) {
            cout << "None" << endl;
        } else {
            if (a == 1) {
                cout << "Left" << endl;
            } else if (d == 1) {
                cout << "Right" << endl;
            } else if (w == 1) {
                cout << "Jump" << endl;
            } else if (s == 1) {
                cout << "Crouch" << endl;
            } else {
                cout << "None" << endl;
            }
        }
        Sleep(100);
    }
    return 0;
}

运行错误QAQ


0
已采纳
丁梓豪
丁梓豪
新手天翼
新手天翼

还要再加个头文件

#include <windows.h>

跪求采纳

0
0
我要回答