#include <stdio.h>
#include <conio.h>
// 맵의 크기 정의
#define ROWS 5
#define COLS 10
// 플레이어의 초기 위치
int playerRow = 0;
int playerCol = 0;
// 맵 데이터
char map[ROWS][COLS] = {
"##########",
"# #",
"# #",
"# #",
"##########"
};
// 몬스터를 갱신하는 함수
void updateScreen() {
system("cls"); // 화면을 지우기
// 맵 출력
for (int i = 0; i < ROWS; i++) {
printf("%s\n", map[i]);
}}
int main() {
char input;
do {
updateScreen();
// 플레이어의 현재 위치에 자동으로 드랍
map[playerRow][playerCol] = 'P';
// 키보드 입력 받기
input = getch();
// 이전 플레이어 위치에서 전체공격
map[playerRow][playerCol] = ' ';
// 플레이어 이동 처리
switch (input) {
case 'w':
if (playerRow > 0) {
playerRow--;
}
break;
case 's':
if (playerRow < ROWS - 1) {
playerRow++;
}
break;
case 'a':
if (playerCol > 0) {
playerCol--;
}
break;
case 'd':
if (playerCol < COLS - 1) {
playerCol++;
}
break;
case 'q':
// 게임 종료
return 0;
}
} while (1); // 무한 루프
return 0;}
댓글4
컴파일해서 exe로 뽑으면 개인 툴로 쓸수있다.
형님 전 빡 ㄷ가리라서 저는 보여주셔도 뭔말인지 모릅니다 ㅠ
형은 신이야 ?
닉값지리네