#include <stdio.h>
#include <conio.h> // getch()
#include <windows.h>
#include <stdlib.h>
#include <time.h>
int nx=0; // 블록의 현재 x좌표
int ny=0; // 블록의 현재 y좌표
int roach;
void gotoxy(int x, int y);
void showblock(bool show,int roach); // 블록을 그리거나, 지운다.
void main()
{
showblock(true,roach);
}
void gotoxy(int x, int y)
{
COORD pos = {x, y};
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),pos);
}
void showblock(bool show,int roach)
{
while(1)
{
for (int i=0; i<1; i++)
{
srand(time(NULL));
int roach=rand()%8;
if(roach==0)
nx++;
else if(roach==1)
ny++;
else if(roach==2)
nx--;
else if(roach==3)
ny--;
else if(roach==4)
nx++,ny--;
else if(roach==5)
nx++,ny++;
else if(roach==6)
nx--,ny++;
else if(roach==7)
nx--,ny--;
gotoxy( nx, ny ); // 현재위치를 중심으로 해서, 구조체에 등록된 좌표에 따라 커서를 이동시킨다.
if (show == true)
{
printf(\"@\");
}
else
printf(\" \");
if(nx>10)
nx=10;
if(nx<0)
nx=0;
if(ny>10)
ny=10;
if(ny<0)
ny=0;
if(nx==10&&ny==10)
break;
}
Sleep(100);
}
}
여기까지짯는데 있자나 자취를 없애는거랑요 ,,,,그 머랄까 벌레가 움직이는게 이어져야되는데
뜬금없이 다른데서 튀어나오고 막 ....뭐라고 설명해야되지 암튼 이것좀 알려주세요
댓글 0