#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
#include <conio.h>
#include <time.h>
void gotoxy(int x, int y){
COORD pos;
pos.X = x - 1;
pos.Y = y - 1;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), pos);
}
void moveA(){
int ch;
system("cls");
ch = getch();
printf("\n\n문자 출력: ");
if (ch >= 32 && ch <= 126){
printf("%c\n", ch);
} else{
printf("(출력 불가 문자)\n");
}
printf("정수 코드값: %d\n", ch);
Sleep(2000);
}
void arrow_A(){
int ch;
int ext;
int x = 10;
int y = 10;
int old_x;
int old_y;
int B_x = 10;
int B_y = 10;
int old_B_x;
int old_B_y;
gotoxy(x, y);//커서시작 위치
while(1){
old_x = x;
old_y = y;
old_B_x = B_x;
old_B_y = B_y;
ch = getch();
if(ch == 0 || ch == 224){
ext = getch();
if(ext == 72 && y>1) y--;
if(ext == 80 && y<25) y++;
if(ext == 75 && x>1) x--;
if(ext == 77 && x<80) x++;
}else {
if(ch == 119 && B_y>1) //w
B_y--;
if(ch == 97 && B_x>1) //a
B_x--;
if(ch == 115 && B_y<25) //s
B_y++;
if(ch == 100 && B_x<80) //d
B_x++;
}
if(old_x != x || old_y != y){
gotoxy(old_x, old_y);
printf(" ");
gotoxy(x, y);
printf("A");
}
if(old_B_x != B_x || old_B_y != B_y){
gotoxy(old_B_x, old_B_y);
printf(" ");
gotoxy(B_x, B_y);
printf("B");
}
}
}
int main(){
while(1){
arrow_A();
}
}
To embed this project on your website, copy the following code and paste it into your website's HTML: