c++小游戏-跳舞的线(无障碍)

c++跳舞的线

我做的太弱了,各位巨佬们不喜勿喷!
#include<stdio.h>
#include<stdlib.h>
#include<windows.h>
#include<iostream>
#include<list>
#include<cmath>
#include<ctime>
#define KEY_DOWN(VK_NONAME) ((GetAsyncKeyState(VK_NONAME) & 0x8000) ? 1:0)
//上面那句是抄的(QAQ)
using namespace std;

HWND hwnd=GetForegroundWindow();

list<string> map;// 177*50

string s;

string line1="                                                                                        ▁▃▆█";
string line2="                                                                                        █▆▃▁";//线头

bool down;

int way=1,c=0,fjyd,size,p=0;

string move(string s) {//附加移动
    if(fjyd<0) {
        for(int i=0; i<abs(fjyd); i++) {
            s=" "+s;
        }
    }
    if(fjyd>0) {
        for(int i=0; i<abs(fjyd); i++) {
            s.erase(0,1);
        }
    }
    return s;
}

int main() {
    system("color 62");
    system("mode con cols=480 lines=250");
    ShowWindow(hwnd,SW_MAXIMIZE);
    while(1) {
        cout<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl;//别问我这是用来干啥的~(QAQ)~
        if(KEY_DOWN(MOUSE_MOVED)||KEY_DOWN(MOUSE_EVENT)||KEY_DOWN(VK_SPACE)||KEY_DOWN(MOUSE_WHEELED)) {//侦测鼠标按下(还支持空格、右键和滚轮)
            if(!down) {
                way=1-way;
            }
            down=1;
        } else {
            down=0;
        }
        if(way) {
            line1.erase(0,6);
            line2.erase(0,6);
        } else {
            line1="      "+line1;
            line2="      "+line2;
        }
        size=line1.size();
        fjyd=0-(93-size)/12;
        line1=move(line1);
        line2=move(line2);//防止线头撞墙
        if(line1.size()<4||line2.size()>186) break;
        if(map.size()==24) map.pop_back();
        if(way) map.push_front(""+line1);
        else map.push_front(""+line2);
        if(way) {//画图
            for(int i=0; i<map.size()-1; i++) {
                s=map.front();
                s=move(s);
                cout<<s<<endl;
                map.push_back(s);
                map.pop_front();
            }
            s=map.front();
            s=move(s);
            cout<<s;
            map.push_back(s);
            map.pop_front();
        } else {
            for(int i=0; i<map.size()-1; i++) {
                s=map.front();
                s=move(s);
                cout<<s<<endl;
                map.push_back(s);
                map.pop_front();
            }
            s=map.front();
            s=move(s);
            cout<<s;
            map.push_back(s);
            map.pop_front();
        }
        if(KEY_DOWN(MOUSE_MOVED)||KEY_DOWN(MOUSE_EVENT)||KEY_DOWN(VK_SPACE)||KEY_DOWN(MOUSE_WHEELED)) {
            if(!down) {
                way=1-way;
            }
            down=1;
        } else {
            down=0;
        }
        Sleep(30);
        if(KEY_DOWN(MOUSE_MOVED)||KEY_DOWN(MOUSE_EVENT)||KEY_DOWN(VK_SPACE)||KEY_DOWN(MOUSE_WHEELED)) {
            if(!down) {
                way=1-way;
            }
            down=1;
        } else {
            down=0;
        }
        Sleep(30);//等待0.03秒
        system("cls");//清屏
    }
}
~Orz=3

各位巨佬们请留下宝贵建议!

发布了1 篇原创文章 · 获赞 10 · 访问量 2625
展开阅读全文

没有更多推荐了,返回首页

©️2019 CSDN 皮肤主题: 大白 设计师: CSDN官方博客

分享到微信朋友圈

×

扫一扫,手机浏览