新游戏。

· · 个人记录

准备做一个下落式音游,现在正在解决音频导入的问题。

目前代码:

#include<bits/stdc++.h>
#include<windows.h>
#define keyd(VK_NONAME) ((GetAsyncKeyState(VK_NONAME) & 0x8000) ? 1:0)
#define slp(__TIME__) Sleep(__TIME__)
#define clr system("cls")
#define pus system("pause")
#define int long long
using namespace std;
const int N = 32, M = 21;
bool tg;
char a[N + 1][M + 1],zm[]={' ','A','S','D','F'};
struct PM {
    char c;
    bool b,is_;
} b[N + 1][M + 1];
inline void next_step(){
    for(int i=N;i>=1;i--){
        for(int j=2;j<=M-1;j++){
            if(b[i][j].b){
                if(!b[i][j].is_){
                    if(i==N){
                        b[i][j]={0,0,0};
                    }
                    else{
                        swap(b[i][j],b[i-1][j]);//由于是倒序,这里保证一定是空的
                        b[i-1][j].is_=1;
                    }
                }
                else{
                    b[i][j].is_=0;
                }
            }
        }
    }
}
inline void setcol(WORD col) {
    SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), col);
}
inline void csh() {
    setcol(7);
    for (int i = 1; i <= N; i++) {
        a[i][1] = '|';
        for (int j = 2; j <= M - 1; j++) {
            a[i][j] = ' ';
        }
        a[i][M] = '|';
    }
    a[N - 2][4] = 'A';
    a[N - 2][9] = 'S';
    a[N - 2][14] = 'D';
    a[N - 2][19] = 'F';
}
inline void print(string s, int jg = 20) {
    for (auto v : s) {
        cout << v;
        slp(jg);
    }
}
inline void put() {
    for (int i = 1; i <= N; i++) {
        for (int j = 1; j <= M; j++) {
            if (b[i][j].b) {
                setcol(10);
                cout << b[i][j].c;
                setcol(7);
            } else cout << a[i][j];
        }
        cout << '\n';
    }
    cout << '|';
    for (int j = 2; j <= M - 1; j++) {
        cout << "_";
    }
    cout << "|\n";
}
inline void st(char type) {
    if (type == 'A') {
        b[1][4].c = 'A';
        b[1][4].b = 1;
    }
    if (type == 'S') {
        b[1][9].c = 'S';
        b[1][9].b = 1;
    }
    if (type == 'D') {
        b[1][14].c = 'D';
        b[1][14].b = 1;
    }
    if (type == 'A') {
        b[1][19].c = 'F';
        b[1][19].b = 1;
    }
}
inline void runmusic(int mus) {
    vector<int>m={};
    if (mus == 0) {//新手教程
        m={1,0,0,2,0,0,3,0,0,4};
        put();
        print("您应该也知道了,这是我们的谱面。\n");
        slp(500);
        clr;
        put();
        print("首先下落的是 hit,您需要在合适的时候点击它。\n");
        slp(1000);
        clr;
        for(int i=0;i<=9;i++){
            if(m[i]!=0){
                st(zm[m[i]]);
            }
            put();
            next_step();
            slp(400);
            clr;
        }
        print("笑死我了,我只做了 hit 哈哈哈哈!\n但是没有关系,我照样可以出纵连和交互!\n准备好了吗?\n");
        slp(2500);

        return;
    }
}
signed main() {
//  ios::sync_with_stdio(0);
    csh();
    print("你好!欢迎来到 MFIG!接下来由我给你看看玩法吧!\n");
    slp(2000);
    pus;
    put();
    print("看到了吗?屏幕下面有 A S D F 这几个字母,当对应字母落下时,你需要按键盘上的字母。\n");
    slp(5000);
    pus;
    clr;
    print("相信你已经知道玩法了,我们来做一个新手教程吧!\n哦对了,在接下来的 5s 内按下键盘上的 E 可以跳过新手教程!\n");
    int k = 220;
    while (k--) {
        slp(1);
        if (keyd('E')) {
            tg = 1;
            print("看来您选择了跳过新手教程。\n");
            break;
        }
    }
    if (!tg) {
        clr;
        print("您选择了观看新手教程!\n");
        runmusic(0);
    }
    clr;
    print("感谢游玩,目前只更新到了新手教程UwU\n");
    pus;
    return 0;
}