목차
main.cpp 2.47KB
Task08(미로찾기).sln 905바이트
Task08(미로찾기).vcproj 3.51KB
Task08(미로찾기).sln 905바이트
Task08(미로찾기).vcproj 3.51KB
본문내용
#include
using namespace std;
//==============================================================================//
// ※ 미로찾기 (파일처리)
// - 콘솔을 이용한 간단한 미로찾기 게임을 만들어보자.
// - 학습내용 :
// 파일을 읽고 쓰는 법 / 콘솔모드에서 커서 이동법 / 2배열 포인터 넘기기
//==============================================================================//
#include
#include
#define MAP_X 20
#define MAP_Y 10
#define LEFT 75
#define RIGHT 77
#define UP 72
#define DOWN 80
#define ESC 27
// 커서이동 //
void MoveCursor(int x, int y)
{
COORD Cur;
Cur.X = x;
Cur.Y = y;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),Cur);
}
// 맵이동가능 체크 //
int MoveCheck(int (*iMap)[MAP_X], int player_y, int player_x)
{
return *(*(iMap+player_y)+player_x) ? 0:1;
}
// 맵로드 //
bool LoadMap(int (*iMap)[MAP_X])
{
FILE* fRead;
fopen_s(&fRead, "File\\map.txt", "r");
if(!(fRead))
{
printf("맵을 로드하지 못하였습니다.\n");
return false;
}
for(int iLoop1=0; iLoop1
{
for(int iLoop2=0; iLoop2
{
if(*(*(iMap+iLoop1)+iLoop2) = fgetc(fRead)-'0')
printf("#");
else
printf(" ");
}
fgetc(fRead);
puts("");
}
fclose(fRead);
MoveCursor(MAP_X-2, MAP_Y-2);
printf("G");
return true;
}
using namespace std;
//==============================================================================//
// ※ 미로찾기 (파일처리)
// - 콘솔을 이용한 간단한 미로찾기 게임을 만들어보자.
// - 학습내용 :
// 파일을 읽고 쓰는 법 / 콘솔모드에서 커서 이동법 / 2배열 포인터 넘기기
//==============================================================================//
#include
#include
#define MAP_X 20
#define MAP_Y 10
#define LEFT 75
#define RIGHT 77
#define UP 72
#define DOWN 80
#define ESC 27
// 커서이동 //
void MoveCursor(int x, int y)
{
COORD Cur;
Cur.X = x;
Cur.Y = y;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),Cur);
}
// 맵이동가능 체크 //
int MoveCheck(int (*iMap)[MAP_X], int player_y, int player_x)
{
return *(*(iMap+player_y)+player_x) ? 0:1;
}
// 맵로드 //
bool LoadMap(int (*iMap)[MAP_X])
{
FILE* fRead;
fopen_s(&fRead, "File\\map.txt", "r");
if(!(fRead))
{
printf("맵을 로드하지 못하였습니다.\n");
return false;
}
for(int iLoop1=0; iLoop1
for(int iLoop2=0; iLoop2
if(*(*(iMap+iLoop1)+iLoop2) = fgetc(fRead)-'0')
printf("#");
else
printf(" ");
}
fgetc(fRead);
puts("");
}
fclose(fRead);
MoveCursor(MAP_X-2, MAP_Y-2);
printf("G");
return true;
}
추천자료
ms비주얼 c++ 로 만든 큐 자료구조 구현 소스 파일
Visual C++로 만든 큐(주석 달려있음)
Visual C++로 만든 스택(주석 달려있음)
Visual C++6.0으로 배우는 C언어 - 제3부 제어문과 순환문(3/7)
[C++]타이머와 삼각함수를 이용한 타원운동
c++의 mfc를 사용한 잠수함 게임
삼각형 외심 구하기C++로 구현)
홀수차 마방진 C++ 소스
Visual C++ 2005 MFC로 제작한 Triple 로직퍼즐 게임 소스
음주측정 구구단 c++(프로그래밍) 파워포인트
Visual C++을 이용한 CRC구현
2011년 1학기 Visual C++프로그래밍 기말시험 핵심체크
객체지향프로그래밍, c++
컴퓨터 - c++이용한 볼링소스
소개글