最近正在写一个小小的game,但是很快就出问题了
就是把这里图片上的(怎么形容呢. . . .)就是后面的red变成两个空格,别问我为什么是两个空格,懂的人都懂
我搞了好多次都不行,++、--、都试了
还是不行
代码发给你们了
会的人qiu qiu帮我解答一下
三克油~
#include<iostream>
#include <stdio.h>
#include <stdlib.h>
#include<conio.h>
#include<windows.h>
#include<string>
#include<time.h>
#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<MAPMAXH-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();
}
}