问题标题: win10加载动画 & 窗口操作类

0
0
已解决
薛乘志
薛乘志
初级启示者
初级启示者

效果图(纯字符画)

#include <bits/stdc++.h>
#include <windows.h>
#include <conio.h>

namespace std { //窗口操作类
    class WINDOW {
        public:
            HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);
            HANDLE hIn = GetStdHandle(STD_INPUT_HANDLE);
            HWND hwnd = GetForegroundWindow();
            bool set_title(string title) {
                return SetConsoleTitleA(title.c_str());
            }
            bool set_size(short width, short height) {
                bool err = 0;
                SMALL_RECT wrt = {0, 0, short(width - 1), short(height - 1)};
                err |= SetConsoleWindowInfo(hOut, true, &wrt);
                COORD coord = {width, height};
                return err | SetConsoleScreenBufferSize(hOut, coord);
            }
            bool set_color(int ForgC, int BackC) {
                WORD wColor = ((BackC & 0x0F) << 4) + (ForgC & 0x0F);
                return SetConsoleTextAttribute(hOut, wColor);
            }
            bool set_pos(short x, short y) {
                COORD coord = {x, y};
                return SetConsoleCursorPosition(hOut, coord);
            }
            bool set_cursor(bool Visible) {
                CONSOLE_CURSOR_INFO CursorInfo;
                GetConsoleCursorInfo(hOut, &CursorInfo);
                CursorInfo.bVisible = Visible;
                return SetConsoleCursorInfo(hOut, &CursorInfo);
            }
            bool close_quick_edit() {
                DWORD mode;
                GetConsoleMode(hIn, &mode);
                mode &= ~ENABLE_QUICK_EDIT_MODE;
                mode &= ~ENABLE_INSERT_MODE;
                mode &= ~ENABLE_MOUSE_INPUT;
                return SetConsoleMode(hIn, mode);
            }
            int get_char() {
                return getch();
            }
            bool judge_key_down(int key) {
                return GetAsyncKeyState(key) & 0x8000;
            }
            POINT get_cursor_point() {
                POINT p;
                GetCursorPos(&p);
                return p;
            }
            void sleep(int seconds) {
                Sleep(seconds);
            }
            void cls() {
                system("cls");
            }
    };
}

using namespace std;

WINDOW w;

int main() { //加载动画
    w.set_cursor(0);
    while (1) {
        printf("        \n");
        printf("        \n");
        printf("        \n");
        printf("  ·    \n");
        w.set_pos(0, 0);
        Sleep(200);
        printf("        \n");
        printf("        \n");
        printf("·      \n");
        printf("  ·    \n");
        w.set_pos(0, 0);
        Sleep(100);
        printf("        \n");
        printf("·      \n");
        printf("·      \n");
        printf("  ·    \n");
        w.set_pos(0, 0);
        Sleep(100);
        printf("  ·    \n");
        printf("·      \n");
        printf("·      \n");
        printf("  ·    \n");
        w.set_pos(0, 0);
        Sleep(100);
        printf("  ·    \n");
        printf("·      \n");
        printf("·      \n");
        printf("        \n");
        w.set_pos(0, 0);
        Sleep(100);
        printf("  ·    \n");
        printf("·      \n");
        printf("        \n");
        printf("        \n");
        w.set_pos(0, 0);
        Sleep(200);
        printf("  ··  \n");
        printf("        \n");
        printf("        \n");
        printf("        \n");
        w.set_pos(0, 0);
        Sleep(200);
        printf("    ·  \n");
        printf("        \n");
        printf("        \n");
        printf("        \n");
        w.set_pos(0, 0);
        Sleep(200);
        printf("    ·  \n");
        printf("      ·\n");
        printf("        \n");
        printf("        \n");
        w.set_pos(0, 0);
        Sleep(200);
        printf("    ·  \n");
        printf("      ·\n");
        printf("      ·\n");
        printf("        \n");
        w.set_pos(0, 0);
        Sleep(100);
        printf("    ·  \n");
        printf("      ·\n");
        printf("      ·\n");
        printf("    ·  \n");
        w.set_pos(0, 0);
        Sleep(100);
        printf("        \n");
        printf("      ·\n");
        printf("      ·\n");
        printf("  ··  \n");
        w.set_pos(0, 0);
        Sleep(100);
        printf("        \n");
        printf("      ·\n");
        printf("·    ·\n");
        printf("  ··  \n");
        w.set_pos(0, 0);
        Sleep(100);
        printf("        \n");
        printf("·      \n");
        printf("·    ·\n");
        printf("  ··  \n");
        w.set_pos(0, 0);
        Sleep(100);
        printf("  ·    \n");
        printf("·      \n");
        printf("·      \n");
        printf("  ··  \n");
        w.set_pos(0, 0);
        Sleep(100);
        printf("  ·    \n");
        printf("·      \n");
        printf("·      \n");
        printf("  ··  \n");
        w.set_pos(0, 0);
        Sleep(100);
        printf("  ·    \n");
        printf("·      \n");
        printf("·      \n");
        printf("  ·    \n");
        w.set_pos(0, 0);
        Sleep(100);
        printf("  ·    \n");
        printf("·      \n");
        printf("·      \n");
        printf("  ·    \n");
        w.set_pos(0, 0);
        Sleep(100);
        printf("  ·    \n");
        printf("·      \n");
        printf("·      \n");
        printf("        \n");
        w.set_pos(0, 0);
        Sleep(100);
        printf("  ··  \n");
        printf("        \n");
        printf("        \n");
        printf("        \n");
        w.set_pos(0, 0);
        Sleep(200);
        printf("    ·  \n");
        printf("        \n");
        printf("        \n");
        printf("        \n");
        w.set_pos(0, 0);
        Sleep(200);
        printf("    ·  \n");
        printf("      ·\n");
        printf("        \n");
        printf("        \n");
        w.set_pos(0, 0);
        Sleep(200);
        printf("    ·  \n");
        printf("      ·\n");
        printf("      ·\n");
        printf("        \n");
        w.set_pos(0, 0);
        Sleep(100);
        printf("    ·  \n");
        printf("      ·\n");
        printf("      ·\n");
        printf("    ·  \n");
        w.set_pos(0, 0);
        Sleep(100);
        printf("        \n");
        printf("      ·\n");
        printf("      ·\n");
        printf("    ·  \n");
        w.set_pos(0, 0);
        Sleep(100);
        printf("        \n");
        printf("        \n");
        printf("      ·\n");
        printf("    ·  \n");
        w.set_pos(0, 0);
        Sleep(100);
        printf("        \n");
        printf("        \n");
        printf("        \n");
        printf("    ·  \n");
        w.set_pos(0, 0);
        Sleep(200);
    }
    return 0;
}

 


0
已采纳
吕梓瑜
吕梓瑜
初级天翼
初级天翼

wow!这个可以申精吗?

我要回答