• 个人简介

    我是没有极限的,我之道,便是斩尽世间所有之敌!(下面还有)
    (看到的是给)
    #include <windows.h>
    #include
    #include
    #include
    #include
    #include
    #include
    #include
    #include
    #include <conio.h>
    using namespace std;
    #define H GetStdHandle(STD_OUTPUT_HANDLE)
    #define S(c) SetConsoleTextAttribute(H, c)
    #define K(n) (GetAsyncKeyState(n) & 0x8000)
    string int2str(int num)
    {
    ostringstream oss;
    oss << num;
    return oss.str();
    }
    void P(int x, int y)
    {
    COORD cd;
    cd.X = (SHORT)x;
    cd.Y = (SHORT)y;
    SetConsoleCursorPosition(H, cd);
    }
    struct B
    {
    int x, y, w, h;
    string t;
    B(int x_, int y_, int w_, int h_, string t_) : x(x_), y(y_), w(w_), h(h_), t(t_) {}
    };
    vector vB;
    B cB(45, 15, 12, 3, "Create Save");
    string cf = "";
    int cl = 1;
    void dB(B b, int c)
    {
    S(c);
    P(b.x, b.y);
    cout << "┏";
    for (int i = 0; i < b.w - 2; ++i)
    cout << "━";
    cout << "┓";
    P(b.x, b.y + 1);
    cout << "┃ " << b.t << " ┃";
    P(b.x, b.y + 2);
    cout << "┗";
    for (int i = 0; i < b.w - 2; ++i)
    cout << "━";
    cout << "┛";
    }
    void menu()
    {
    vB.clear();
    for (int i = 0; i < 6; ++i)
    {
    string name = "Save " + int2str(i + 1);
    vB.push_back(B(2 + i * 11, 2, 10, 3, name));
    }
    system("cls");
    S(12);
    P(20, 10);
    cout << "?? --- [1-6] 选存档 | [C] 新建 | 龙年行大运 --- ??";
    for (size_t i = 0; i < vB.size(); ++i)
    dB(vB[i], 14);
    dB(cB, 14);
    while (true)
    {
    char k = getch();
    if (k >= '1' && k <= '6')
    {
    cf = "save" + string(1, k) + ".dat";
    ifstream f(cf.c_str());
    if (f >> cl)
    {
    system("cls");
    S(14);
    cout << "[加载成功] 存档 " << k;
    Sleep(500);
    return;
    }
    else
    {
    P(25, 12);
    S(14);
    cout << "存档空, 请按 [C]!";
    }
    }
    if (k == 'c' || k == 'C')
    {
    P(25, 12);
    S(14);
    cout << "输入ID(1-6):";
    int n;
    cin >> n;
    if (n >= 1 && n <= 6)
    {
    cf = "save" + int2str(n) + ".dat";
    cl = 1;
    ofstream f(cf.c_str());
    f << 1;
    system("cls");
    S(12);
    cout << "[开运] 创建完毕!";
    Sleep(500);
    return;
    }
    }
    }
    }
    struct M
    {
    float x;
    int b, r, d;
    M(float x_, int b_, int r_, int d_) : x(x_), b(b_), r(r_), d(d_) {}
    };
    int mW;
    int h[200];
    int bgP[200];
    float px, py, vY, sp, scX;
    vector os;
    vector ms;
    string saveFile;
    int curLv;
    int hp;
    int invincible;
    void gn()
    {
    os.clear();
    ms.clear();
    for (int x = 0; x < mW; ++x)
    {
    h[x] = (x < 10 || x > mW - 10) ? 12 : (rand() % 10 < 1 ? 25 : 9 + rand() % 3);
    bgP[x] = rand() % 20;
    if (x > 15 && x < mW - 15 && h[x] < 15)
    {
    if (rand() % 9 < 1)
    os.push_back(x);
    if (rand() % 25 < 1)
    ms.push_back(M((float)x, x, 5 + rand() % 5, 1));
    }
    }
    }
    void sv()
    {
    ofstream f(saveFile.c_str());
    f << curLv;
    }
    void game()
    {
    mW = 200;
    px = 10;
    py = 10;
    vY = 0;
    sp = 1.8f;
    scX = 0;
    saveFile = cf;
    curLv = cl;
    hp = 3;
    invincible = 0;
    gn();
    CONSOLE_CURSOR_INFO ci;
    ci.dwSize = 1;
    ci.bVisible = FALSE;
    SetConsoleCursorInfo(H, &ci);
    system("cls");
    while (curLv <= 100)
    {
    P(0, 0);
    if (invincible > 0)
    invincible--;
    if (K(38))
    sp += 0.15f;
    if (K(40))
    {
    sp -= 0.15f;
    if (sp < 0.3f)
    sp = 0.3f;
    }
    if (K(32) && py >= h[(int)px])
    vY = -2.6f;
    if (K('D') && px < mW - 5)
    px += sp;
    if (K('A') && px > 2)
    px -= sp;
    if (K('L'))
    {
    curLv++;
    px = 10;
    py = 10;
    vY = 0;
    hp = 3;
    invincible = 0;
    gn();
    sv();
    system("cls");
    Sleep(200);
    continue;
    }
    py += vY;
    vY += 0.7f;
    int ipx = (int)px;
    if (ipx < 0)
    ipx = 0;
    if (ipx >= mW)
    ipx = mW - 1;
    if (py > h[ipx] && h[ipx] < 15)
    {
    py = (float)h[ipx];
    vY = 0;
    }
    bool hit = false;
    for (size_t i = 0; i < ms.size(); ++i)
    {
    M &m = ms[i];
    m.x += 0.25f * m.d;
    if (fabs(m.x - m.b) > m.r)
    m.d *= -1;
    int mx = (int)m.x;
    if (mx >= 0 && mx < mW)
    {
    if (mx == ipx && fabs(py - h[ipx]) < 1.0f)
    hit = true;
    }
    }
    for (size_t i = 0; i < os.size(); ++i)
    {
    int o = os[i];
    if (o == ipx && fabs(py - h[ipx]) < 1.0f)
    hit = true;
    }
    if (py > 18)
    hit = true;
    if (hit && invincible <= 0)
    {
    hp--;
    invincible = 25;
    if (hp <= 0)
    {
    hp = 3;
    px = 10;
    py = 10;
    vY = 0;
    }
    }
    float targetX = px - 20;
    scX += (targetX - scX) * 0.4f;
    if (scX < 0)
    scX = 0;
    if (scX > mW - 61)
    scX = mW - 61;
    int curX = (int)scX;
    int bgX = (int)(scX * 0.4f);
    S(14);
    P(0, 0);
    cout << "【0玩家 $终点 M怪 ▲刺 =地板】关卡:" << curLv << " 速度:" << sp << " HP:" << hp; for (int y = 4; y < 18; ++y) { P(0, y); cout << " "; P(0, y); for (int x = curX; x < curX + 60; ++x) { if (x < 0 || x >= mW) { cout << " "; continue; } if (x == ipx && y == (int)py) { if (invincible > 0 && (invincible % 4 < 2)) S(0); else S(14); cout << "0"; } else if (y == h[x]) { bool im = false, io = false; for (size_t i = 0; i < ms.size(); ++i) { if ((int)ms[i].x == x) im = true; } for (size_t i = 0; i < os.size(); ++i) { if (os[i] == x) io = true; } if (io) { S(11); cout << "▲"; } else if (im) { S(14); cout << "M"; } else { S(12); cout << "="; } } else if (x == 195 && y == 10) { S(14); cout << "$";
    }
    else
    {
    int pPos = (x + bgX) % mW;
    if (y == 5 && bgP[pPos] == 1)
    {
    S(8);
    cout << "·";
    }
    else if (y == 7 && bgP[pPos] == 2)
    {
    S(8);
    cout << "+";
    }
    else
    {
    cout << " ";
    }
    }
    }
    }
    cout.flush();
    if (px >= 195)
    {
    curLv++;
    px = 10;
    py = 10;
    vY = 0;
    hp = 3;
    invincible = 0;
    scX = 0;
    gn();
    sv();
    system("cls");
    S(14);
    P(0, 0);
    cout << "大吉大利,今晚吃鸡";
    cout.flush();
    Sleep(600);
    system("cls");
    }
    Sleep(110);
    }
    }
    int main()
    {
    srand((unsigned)time(NULL));
    menu();
    game();
    system("pause");
    return 0;
    }

  • 通过的题目

  • 最近活动

    This person is lazy and didn't join any contests or homework.
  • 最近编写的题解

题目标签

GESP一级赛训
53
排序
13
递推
12
贪心
11
排序函数
6
二分
6
倍增法
4
STL排序函数
1