Warning: file_get_contents(https://whois.pconline.com.cn/jsLabel.jsp?ip=127.0.0.1) [function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.1 503 Service Temporarily Unavailable in D:\wwwroot\huidong\wwwroot\function.inc.php on line 884
点赞、投币、收藏和三连的大量窗口弹出效果(效果不好,只是记录) - huidong

huidong

首页 | 会员登录 | 关于争取 2022 寒假做出汇东网 Ver3.0.0 !
搜索文章


#include "HiEasyX.h"

#define WND_NUM 70

#define GIF_LIKE        0
#define GIF_COIN        1
#define GIF_COLLECT        2
#define GIF_SANLIAN        3

HiEasyX::Gif gif[4];

HWND pWnd[WND_NUM] = {};
int pGifType[WND_NUM] = {};
int num = 0;

bool play_done = false;

void Init()
{
    gif[GIF_LIKE].load(L"./点赞.gif");
    gif[GIF_COIN].load(L"./投币.gif");
    gif[GIF_COLLECT].load(L"./收藏.gif");
    gif[GIF_SANLIAN].load(L"./三连.gif");
}

void Play()
{
    IMAGE img[3];
    for (int i = 0; i < 3; i++)
    {
        img[i].Resize(gif[i].getOrginWidth(), gif[i].getOrginHeight());
        gif[i].bind(GetImageHDC(&img[i]));
        gif[i].play();
    }

    clock_t time = 0;
    while (true)
    {
        int j = 0;
        for (int i = 0; i < 3; i++)
        {
            if (gif[i].isPlaying())
            {
                j++;
            }
            gif[i].draw();
        }

        if (time == 0 && num == WND_NUM)
        {
            time = clock();
        }

        if (time != 0 && ((clock() - time) / CLOCKS_PER_SEC >= 3))
        {
            play_done = true;
            break;
        }

        for (int i = 0; i < num; i++)
        {
            BEGIN_TASK_WND(pWnd[i]);
            putimage(0, 0, &img[pGifType[i]]);
            END_TASK();
            FLUSH_DRAW();
        }

        Sleep (10);
    }
}


int main()
{
    int nScreenW = 1600, nScreenH = 900;
    Init();
    srand((UINT)time(0));

    std::thread(Play).detach();
    Sleep (500);
    for (int i = 0; i < WND_NUM; i++)
    {
        HiEasyX::PreSetWindowPos((rand() * 100) % nScreenW, (rand() * 100) % nScreenH);
        pGifType[i] = rand() % 3;
        pWnd[i] = initgraph(gif[pGifType[i]].getOrginWidth(), gif[pGifType[i]].getOrginHeight());
        num++;
        Sleep (50);
    }

    while (!play_done) Sleep (100);

    int w = gif[GIF_SANLIAN].getOrginWidth();
    int h = gif[GIF_SANLIAN].getOrginHeight();
    HiEasyX::PreSetWindowPos((nScreenW - w) / 2 + 100, (nScreenH - h) / 2);
    initgraph(w, h);

    IMAGE img(w, h);
    gif[GIF_SANLIAN].bind(GetImageHDC(&img));
    gif[GIF_SANLIAN].play();

    for (int i = 0; i < gif[GIF_SANLIAN].getFrameCount(); i++)
    {
        BEGIN_TASK();
        gif[GIF_SANLIAN].drawFrame(i);
        putimage(0, 0, &img);
        END_TASK();
        FLUSH_DRAW();
        Sleep (gif[GIF_SANLIAN].getDelayTime(i));
    }

    Sleep (3000);
    closegraph();

    return 0;
}


需要目录下的 gif 文件。






返回首页


Copyright (C) 2018-2024 huidong