지뢰찾기 게임을 구현한 소스 분석중인데요
핵심 부분 소스만 쓸게요
헤더파일 中
#include <windows.h>
#include "resource.h"
#include <math.h>
#include <stdilb.h>
enum STATE {EMPTY=0, ONE, TWO, THREE, FOUR, FIVE, SIX, SEVEN, EIGHT, BOMB=99};
enum ISOPEN {CLOSE=0, OPEN, FLAG, QUESTION};
enum PLAY {STOP=0, START};
enum BUTTON {PUSH_UP=0, PUSH_DOWN};
.
.
.
.
.
.
메인cpp파일 中
#include "total.h"
static int count_BOMB=10;
static int count_1=10;
int size_x=173;
int size_y=263;
static int _X_=9;
static int _Y_=9;
static int push=0;
struct BLOCK
{
STATE state;
ISOPEN isopen;
};
BLOCK block[9][9];
.
.
.
HINSTANCE g_hInst;
.
.
.
.
.
.
RECT rectangle(const int x, const int y)
{
RECT rr={16*(x)+12, 16*(y)_55, 16*(x+1)+12, 16*(y+1)+55};
return rr;
}
.
.
.
.
.
.
BOOL BLINK_FIND(int x, int y, HWND hwnd)
{
핵심 부분 소스만 쓸게요
헤더파일 中
#include <windows.h>
#include "resource.h"
#include <math.h>
#include <stdilb.h>
enum STATE {EMPTY=0, ONE, TWO, THREE, FOUR, FIVE, SIX, SEVEN, EIGHT, BOMB=99};
enum ISOPEN {CLOSE=0, OPEN, FLAG, QUESTION};
enum PLAY {STOP=0, START};
enum BUTTON {PUSH_UP=0, PUSH_DOWN};
.
.
.
.
.
.
메인cpp파일 中
#include "total.h"
static int count_BOMB=10;
static int count_1=10;
int size_x=173;
int size_y=263;
static int _X_=9;
static int _Y_=9;
static int push=0;
struct BLOCK
{
STATE state;
ISOPEN isopen;
};
BLOCK block[9][9];
.
.
.
HINSTANCE g_hInst;
.
.
.
.
.
.
RECT rectangle(const int x, const int y)
{
RECT rr={16*(x)+12, 16*(y)_55, 16*(x+1)+12, 16*(y+1)+55};
return rr;
}
.
.
.
.
.
.
BOOL BLINK_FIND(int x, int y, HWND hwnd)
{
if((x+1) < _X_ && block[x+1][y].state != BOMB &&(block[x+1][y].isopen == CLOSE || block[x+1][y].isopen == QUESTION))
{
block[x+1][y].isopen = OPEN;
RECT r1 = rectangle(x+1, y);
InvalidateRect(hWnd, &r1, FALSE);
if(block[x+1][y].state == EMPTY)
{
BLINK_FIND(x+1, y, hWnd);
}
}
.
.
.
.
.
.
}
return true;
}
궁금한건 bool형 함수인 blink_find함수인데요
x,y에 할당되는 좌표값을 받아서 조건에 따라서 사각형을 그리는데 처음 if문 안의 block식인 [x+1][y]배열식과 if문 안의 if문 배열식이 똑같은데
그러면 blink_find함수가 조건이 맞아서 계속 실행이 된다면 같은 좌표 지점에서 계속 반복 실행이 되지 않나요?
실제로는 그렇게 되지 않는다는데 이유를 동체 모르겠음....ㅠㅠ
재귀호출
이거는 API 질문이 아닌뎅