关于#c++#的问题,如何解决?

最近正在写一个小小的game,但是很快就出问题了

img

就是把这里图片上的(怎么形容呢. . . .)就是后面的red变成两个空格,别问我为什么是两个空格,懂的人都懂
我搞了好多次都不行,++、--、都试了
还是不行
代码发给你们了
会的人qiu qiu帮我解答一下
三克油~


#include
#include 
#include 
#include
#include
#include
#include

#define MAPMAXS 60
#define MAPMAXH 60

using namespace std;



struct player1{
    int x;
    int y;
};
struct player1 red = {58,29};

struct player2{
    int x;
    int y;
};
struct player2 blue = {2,1};


void gotoxy(int x, int y){
    COORD coord;
    coord.X = x;
    coord.Y = y;
    SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);
}

void COLOR_PRINT(const char* s, int color){
    HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE);
    SetConsoleTextAttribute(handle, FOREGROUND_INTENSITY | color);
    printf(s);
    SetConsoleTextAttribute(handle, FOREGROUND_INTENSITY | 7);
}

void drawMap(){
    gotoxy(red.x,red.y);
    COLOR_PRINT("■",4);
    gotoxy(blue.x,blue.y);
    COLOR_PRINT("■",1);
    for(int i=0;i<=MAPMAXS;i+=2){
        gotoxy(i,0);
        printf("■");
        gotoxy(i,MAPMAXS-30);
        printf("■");
    }
    for(int i=1;i-30;i++){
        gotoxy(0,i);
        printf("■");
        gotoxy(MAPMAXH,i);
        printf("■");
    }
    gotoxy(MAPMAXH - 2, 0);
    printf("\n");
    
}

void move(){
    char key;
    key=_getch();
    if(key=='w'&&red.y-1!=0){
        red.y--;

        drawMap();
        
    } 
    else if(key=='s'&&red.y+1!=30){
        red.y++;
    }
}

void initload(){
    
}

void update(){
    
}
int main(){
    drawMap();
    while(1){
        move();
    }
}

6

没有实现玩家的碰撞检测,即两个玩家可以重叠在同一位置。
只实现了红色玩家的移动,蓝色玩家未实现移动。
代码结构和命名不够清晰,建议进行重构。