问题标题: 闪屏跑酷1.0

3
1
已解决
廖睿轩
廖睿轩
新手光能
新手光能

我的新游戏,在编程平台发不了,就过来了!

代码:

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

using namespace std;

char mmp[1001][1001] = {"                                                                                                                                                                                                        ",
                        "                                                                                                                                                                                                        ",
                        "                                                                                   ###                            #  #  #  #  #  #  #  ###         ####                              ###                ",
                        "                                                                                                             ##                              ####          ###  # # # #  ###     ##                      ",
                        "                                                                 ##         #####         ####                                                                                             ###          ",
                        "                                                                       ##                              ##                                                                                               ",
                        "                                                                                                ####                                                                                                    ",
                        "                                                                                                                                                                                               ###      ",
                        "                                                            ##                                                                                                                                          ",
                        "                                                                                                                                                                                                    ####",
                        "                                                                                                                                                                                                        ",
                        "                                      ##              ###                                                                                                                                               ",
                        "                          ##                   ####                                                                                                                                                     ",
                        "                  ###           ####                                                                                                                                                                    ",
                        "         ###                             ##                                                                                                                                                             ",
                        "                                                                                                                                                                                                        ",
                        "  O                                                                                                                                                                                                     ",
                        "#####                                                                                                                                                                                                   ",
                        "#####                                                                                                                                                                                                   ",
                        "#####                                                                                                                                                                                                   "
                       };//20 * 200;

char putmmp[20][16];

int jump[20] = {0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, -1, 0, -1, 0, -1, 0, -1};

int main() {

    char ch;

    bool t = 1;

    int x = 16, y = 2, delayjump = 0;

    while (1) {

        Sleep(25);

        if (y - 7 < 0) {

            for (register int i = 0; i < 20; i++) {

                for (register int j = 0; j < 15; j++) {

                    putmmp[i][j] = mmp[i][j];

                }

                putmmp[i][15] = '\n';

            }

        } else if (y + 7 > 199) {

            for (register int i = 0; i < 20; i++) {

                int k = 14;

                for (register int j = 199; j >= 85; j--, k--) {

                    putmmp[i][k] = mmp[i][j];

                }

                putmmp[i][15] = '\n';

            }

        } else {

            for (register int i = 0; i < 20; i++) {

                int k = 0;

                for (register int j = y - 7; j <= y + 7; j++, k++) {

                    putmmp[i][k] = mmp[i][j];

                }

                putmmp[i][15] = '\n';

            }

        }

        system("cls");

        fwrite(putmmp, 1, 20 * 16, stdout);
        printf("%d %d\n", x, y);

        if (delayjump > 0) {

            if (delayjump > 8 && (x + jump[delayjump] == -1 || mmp[x + jump[delayjump]][y] == '#')) {

                delayjump = 5;

            } else {

                if (delayjump <= 8 && x + jump[delayjump] == 19) {

                    mmp[x][y] = ' ';
                    x = 16, y = 2;
                    mmp[x][y] = 'O';

                }

                if (delayjump <= 8 && (x + jump[delayjump] == 20 || mmp[x + jump[delayjump]][y] == '#')) {

                    delayjump = 0;

                } else {

                    mmp[x][y] = ' ';
                    x += jump[delayjump];
                    mmp[x][y] = 'O';
                    delayjump--;

                }

            }


        }

        if (!delayjump) {

            if (x + 1 == 20) {

                mmp[x][y] = ' ';
                x = 16, y = 2;
                mmp[x][y] = 'O';

            }

            if (mmp[x + 1][y] == ' ' && x < 19 && t) {

                t = !t;
                mmp[x][y] = ' ';
                x++;
                mmp[x][y] = 'O';

            } else {

                t = !t;

            }

        }

        if (kbhit()) {

            ch = getch();

            switch(ch) {

                case 27 :

                    exit(0);

                    break;

                case -32 :

                    ch = getch();

                    switch(ch) {

                        case 75 :

                            if (y > 0 && mmp[x][y - 1] == ' ') {

                                mmp[x][y] = ' ';
                                y--;
                                mmp[x][y] = 'O';

                            }

                            break;

                        case 77 :

                            if (y < 199 && mmp[x][y + 1] == ' ') {

                                mmp[x][y] = ' ';
                                y++;
                                mmp[x][y] = 'O';

                            }

                            break;

                        case 72 :

                            if (!delayjump && mmp[x + 1][y] == '#') {

                                delayjump = 18;

                            }

                            break;

                    }

                    break;

            }

        }

    }

    return 0;

}

 


0
1
1
陈俊霖
陈俊霖
新手天翼
新手天翼
#include <bits/stdc++.h>
#include <windows.h>
#include <conio.h>
using namespace std;
namespace nout{
    const HANDLE GSH=GetStdHandle(STD_OUTPUT_HANDLE);
    void SCxy(COORD pos){
        SetConsoleCursorPosition(GSH,pos);
    }
    void gotoxy(int x,int y)
    {
        COORD  pos;
        pos.X=x;
        pos.Y=y;
        SetConsoleCursorPosition(GSH,pos);
    }
    void gofirst(){
        COORD  pos;
        pos.X=0;
        pos.Y=0;
        SetConsoleCursorPosition(GSH,pos);
    }
}
char mmp[1001][1001] = {"                                                                                                                                                                                                        ",
                        "                                                                                                                                                                                                        ",
                        "                                                                                   ###                            #  #  #  #  #  #  #  ###         ####                              ###                ",
                        "                                                                                                             ##                              ####          ###  # # # #  ###     ##                     ",
                        "                                                                 ##         #####         ####                   #  #  #  #  #  #  #  #  #      ####                                ###    ###          ",
                        "                                                                       ##                              ##                                 ####          #                       ###                     ",
                        "                                                               ##       #####          ####     ####       ##                                                                            ###            ",
                        "                                                                    ##                                                                                    ##### # # # #  ### ###               ###      ",
                        "                                                            ##                                ####  #####                                                                                               ",
                        "                                                                                                                                                                                              ###   ####",
                        "                                                          ##                                                                                                                                            ",
                        "                                      ##              ###                                                                                                                                        #####  ",
                        "                          ##                   ####                                                                                                                                                     ",
                        "                  ###           #####               ###                                                                                                                                                 ",
                        "         ###                             ## ####                                                                                                                                                        ",
                        "                       ##    ####                              # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #  # # # #                                                                 ",
                        "  O            ###                    ##                                                                                                                                                                  ",
                        "##### ###                                                     # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #  # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #",
                        "#####                                                                                                                                                                                                   ",
                        "#####                                                                                                                                                                                                   ",
                       };//20 * 200;
char putmmp[20][16];
int jump[20] = {0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, -1, 0, -1, 0, -1, 0, -1};
int main() {
    char ch;
    bool t = 1;
    int x = 16, y = 2, delayjump = 0;
    while (1) {
        Sleep(100);
        if (y - 7 < 0) {
            for (register int i = 0; i < 20; i++) {
                for (register int j = 0; j < 15; j++) {
                    putmmp[i][j] = mmp[i][j];
                }
                putmmp[i][15] = '\n';
            }
        } else if (y + 16 > 199) {
            for (register int i = 0; i < 20; i++) {
                int k = 14;
                for (register int j = 199; j >= 185; j--, k--) {
                    putmmp[i][k] = mmp[i][j];
                }
                putmmp[i][15] = '\n';
            }
        } else {
            for (register int i = 0; i < 20; i++) {
                int k = 0;
                for (register int j = y - 7; j <= y + 7; j++, k++) {
                    putmmp[i][k] = mmp[i][j];
                }
                putmmp[i][15] = '\n';
            }
        }
        nout::gofirst();
        fwrite(putmmp,1,20*16,stdout);
        nout::gotoxy(0,20);
        printf("        ");
        nout::gotoxy(0,20);
        cout<<x<<" "<<y;
        if (delayjump > 0) {
            if (delayjump > 8 && (x + jump[delayjump] == -1 || mmp[x + jump[delayjump]][y] == '#')) {
                delayjump = 5;
            } else {
                if (delayjump <= 8 && x + jump[delayjump] == 19) {
                    mmp[x][y] = ' ';
                    x = 16, y = 2;
                    mmp[x][y] = 'O';
                }
                if (delayjump <= 8 && (x + jump[delayjump] == 20 || mmp[x + jump[delayjump]][y] == '#')) {
                    delayjump = 0;
                } else {
                    mmp[x][y] = ' ';
                    x += jump[delayjump];
                    mmp[x][y] = 'O';
                    delayjump--;
                }
            }
        }
        if (!delayjump) {
            if (x + 1 == 20) {
                mmp[x][y] = ' ';
                x = 16, y = 2;
                mmp[x][y] = 'O';
            }
            if (mmp[x + 1][y] == ' ' && x < 19 && t) {
                t = !t;
                mmp[x][y] = ' ';
                x++;
                mmp[x][y] = 'O';
            } else {
                t = !t;
            }
        }
        if (kbhit()) {
            ch = getch();
            switch(ch) {
                case 27 :
                    exit(0);
                    break;
                case -32 :
                    ch = getch();
                    switch(ch) {
                        case 75 :
                            if (y > 0 && mmp[x][y - 1] == ' ') {
                                mmp[x][y] = ' ';
                                y--;
                                mmp[x][y] = 'O';
                            }
                            break;
                        case 77 :
                            if (y < 199 && mmp[x][y + 1] == ' ') {
                                mmp[x][y] = ' ';
                                y++;
                                mmp[x][y] = 'O';
                            }
                            break;
                        case 72 :
                            if (!delayjump && mmp[x + 1][y] == '#') {
                                delayjump = 18;
                            }
                            break;
                    }
                    break;
            }
        }
    }
    return 0;
}

送你一个2.0

0
0
0
0
0
0
0
0
朱小川
朱小川
缔造者
缔造者

一听到闪屏,我就浑身发抖,上次我就被坑了

我要回答