ㅋㄷㅋㄷㅋㄷ
일부로 공개안할꺼라 일부내용 일부로 짤라서넣었기때매 실행은안될껴~ㅋㄷ
이거 전에 타자로다썼는데..
타자로 다쓴기야 길지 짤라서그러지더길지롱~
#include <windows.h>
#include "resource.h"
#pragma comment ( lib, "winmm" )
LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM);
HINSTANCE g_hInst;
LPCTSTR lpszClass=TEXT("Game1");
HWND hWndMain;
#define MAXUNDO 1000
#define LSTAGE 5
#define MX 32
#define MY 32
#define BX 21
#define BY 20
struct tag_MoveInfo {
char dx:3;
char dy:3;
char bWithPack:2;
int item:5;
int bits:4;
};
tag_MoveInfo MoveInfo[MAXUNDO];
int Undoldx;
HBITMAP gmaps[10];
HBITMAP hman[8];
HBITMAP hpeople[5];
HBITMAP MapOldBitmap;
int stage=1;
int key;
int nMove=0;
int data=0;
int nx,ny;
char ns[BY][BX];
int Manbit;
void DrawScreen(HWND hWnd,HDC hdc);
void Move(int dir);
BOOL TestEnd();
void lnitStage();
void DrawBitmap(HDC hdc,int x,int y,HBITMAP hBit);
void DrawBitmaps(HDC hdc,int x,int y,HBITMAP hBit);
void ErasePack(int x,int y);
void Undo();
//1벽돌/0길/3사람/45678아픈사람/9병원/E입원
char nStage[LSTAGE][BY][BX]={
{
"11111111111111111111",//1
"11111111111111111111",//2
"11111111100000111111",//3
"11119000000000111111",//4
"11111000000109111111",//5
"11111000060011091111",//6
"11111000000000001111",//7
"11111041110001001111",//8
"11001001115005011111",//9
"11000001110000011111",//10
"11011007008001111111",//11
"11011100300000000011",//12
"11011111111000000011",//13
"11011111111111110011",//14
"11911111111111110011",//15
"11111111111111119911",//16
"11111111111111111111",//17
"11111111111111111111",//18
"11111111111111111111",//19
"11111111111111111111",//20
},
{
"11111111111111111111",//1
"11111111111111111111",//2
"11111111111111111111",//3
"11111111111111111111",//4
"11111111111111111111",//5
"11111111999110011111",//6
"11111111000110811111",//7
"11111111000110011111",//8
"11111111001105001111",//9
"11111113000100701111",//10
"11110001000060001111",//11
"11110400000009911111",//12
"11111111000006011111",//13
"11111111000540111111",//14
"11111111999011111111",//15
"11111111111111111111",//16
"11111111111111111111",//17
"11111111111111111111",//18
"11111111111111111111",//19
"11111111111111111111",//20
},
{
"11111111111111111111",//1
"11111111111111111111",//2
"11111111111111111111",//3
"11111190000006011111",//4
"11111101111100011111",//5
"11111901111199111111",//6
"11111001111100111111",//7
"11111000500007111111",//8
"11110010011100111111",//9
"11111004003000011111",//10
"11119000101711611111",//11
"11111110101011011111",//12
"11190000005004011111",//13
"11111119911110011111",//14
"11111111111111111111",//15
"11111111111111111111",//16
"11111111111111111111",//17
"11111111111111111111",//18
"11111111111111111111",//19
"11111111111111111111",//20
},
{
"11111111111111111111",//1
"11111111111111111111",//2
"11111111111111111111",//3
"11199111111111111111",//4
"11100000000000001111",//5
"11100000000000001111",//6
"11100000000000001111",//7
"11100000000800001111",//8
"11900040000000009111",//9
"11100000000700001111",//10
"11100000300800001111",//11
"11100000000800001111",//12
"11900000000560009111",//13
"11100000000400001111",//14
"11100000000000001111",//15
"11100000000000001111",//16
"11100000000000001111",//17
"11111111111119911111",//18
"11111111111111111111",//19
"11111111111111111111",//20
},
{
"11111111111111111111",//1
"11111111111111111111",//2
"11111001111111100111",//3
"11100000001000040111",//4
"11100000800108000111",//5
"11100910011110000111",//6
"11110011111100619111",//7
"11100411111110000011",//8
"11100000111115001111",//9
"11190050009100011111",//10
"11111100000000009111",//11
"11100900110070100111",//12
"11111100111001100111",//13
"11110018000041039111",//14
"11110000010091001111",//15
"11119009009010001111",//16
"11111111110010600111",//17
"11111111111111001111",//18
"11111111111111111111",//19
"11111111111111111111",//20
},
};
int APIENTRY WinMain(HINSTANCE hInstance,HINSTANCE hPrevinstance,LPSTR lpszCmdParam,int nCmdShow)
{
HACCEL hAccel;
HWND hWnd;
MSG Message;
WNDCLASS WndClass;
g_hInst=hInstance;
WndClass.cbClsExtra=0;
WndClass.cbWndExtra=0;
WndClass.hbrBackground=(HBRUSH)GetStockObject(BLACK_BRUSH);
WndClass.hCursor=LoadCursor(hInstance,MAKEINTRESOURCE(IDC_CURSOR1));
WndClass.hIcon=LoadIcon(hInstance,MAKEINTRESOURCE(IDI_ICON1));
WndClass.hInstance=hInstance;
WndClass.lpfnWndProc=WndProc;
WndClass.lpszClassName=lpszClass;
WndClass.lpszMenuName=MAKEINTRESOURCE(IDR_MENU1);
WndClass.style=CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS;
RegisterClass(&WndClass);
hWnd=CreateWindow(lpszClass,TEXT("병원놀이"),WS_CAPTION|WS_MINIMIZEBOX|WS_SYSMENU,
CW_USEDEFAULT,CW_USEDEFAULT,800,600,
NULL,(HMENU)NULL,hInstance,NULL);
ShowWindow(hWnd,nCmdShow);
hAccel=LoadAccelerators(hInstance,MAKEINTRESOURCE(IDR_ACCELERATOR1));
while(GetMessage(&Message,NULL,0,0)){
if(!TranslateAccelerator(hWnd,hAccel,&Message)){
TranslateMessage(&Message);
DispatchMessage(&Message);
}
}
return Message.wParam;
}
BOOL CALLBACK AboutDlgProc(HWND hDlg,UINT iMessage,WPARAM wParam,LPARAM lParam)
{
switch(iMessage){
case WM_INITDIALOG:
return TRUE;
case WM_COMMAND:
switch(LOWORD(wParam)){
case IDOK:
EndDialog(hDlg,IDOK);
return TRUE;
}
break;
}
return FALSE;
}
LRESULT CALLBACK WndProc(HWND hWnd,UINT iMessage,WPARAM wParam,LPARAM lParam)
{
int old;
static int n=-20,r=0,m=0,maini=0;
TCHAR Message[256];
HDC hdc,MemDC;
PAINTSTRUCT ps;
HBRUSH MyBrush,OldBrush;
HBITMAP MyBitmap,OldBitmap;
switch(iMessage)
{
case WM_CREATE:
hWndMain=hWnd;
SetTimer(hWnd,1,50,NULL);
stage=0;
gmaps[0]=LoadBitmap(g_hInst,MAKEINTRESOURCE(IDB_MAP1));//벽
gmaps[1]=LoadBitmap(g_hInst,MAKEINTRESOURCE(IDB_MAP2));//길
gmaps[2]=LoadBitmap(g_hInst,MAKEINTRESOURCE(IDB_MAP3));//엠블란스 뜨기전
gmaps[3]=LoadBitmap(g_hInst,MAKEINTRESOURCE(IDB_MAP4));//엠블란스 된후
gmaps[5]=LoadBitmap(g_hInst,MAKEINTRESOURCE(IDB_IMG1));
gmaps[6]=LoadBitmap(g_hInst,MAKEINTRESOURCE(IDB_IMG2));//중독자
gmaps[7]=LoadBitmap(g_hInst,MAKEINTRESOURCE(IDB_IMG3));
gmaps[8]=LoadBitmap(g_hInst,MAKEINTRESOURCE(IDB_IMG4));
gmaps[9]=LoadBitmap(g_hInst,MAKEINTRESOURCE(IDB_IMG5));
//케릭터 데이터 초기화
hman[0]=LoadBitmap(g_hInst,MAKEINTRESOURCE(IDB_MAN1));
hman[1]=LoadBitmap(g_hInst,MAKEINTRESOURCE(IDB_MAN2));
hman[2]=LoadBitmap(g_hInst,MAKEINTRESOURCE(IDB_MAN3));
hman[3]=LoadBitmap(g_hInst,MAKEINTRESOURCE(IDB_MAN4));
hman[4]=LoadBitmap(g_hInst,MAKEINTRESOURCE(IDB_MAN5));
hman[5]=LoadBitmap(g_hInst,MAKEINTRESOURCE(IDB_MAN6));
hman[6]=LoadBitmap(g_hInst,MAKEINTRESOURCE(IDB_MAN7));
hman[7]=LoadBitmap(g_hInst,MAKEINTRESOURCE(IDB_MAN8));
lnitStage();
return 0;
case WM_PAINT:
if(r==0){
hdc=BeginPaint(hWnd,&ps);
MemDC=CreateCompatibleDC(hdc);
if(n>-21 && n<=-1){ MyBitmap=LoadBitmap(g_hInst,MAKEINTRESOURCE(IDB_BITMAP7)); n++; if(n==-1){n=0;}}
else if(n==0){ MyBitmap=LoadBitmap(g_hInst,MAKEINTRESOURCE(IDB_BITMAP2)); n=1; }
else if(n==1){ MyBitmap=LoadBitmap(g_hInst,MAKEINTRESOURCE(IDB_BITMAP3)); n=2; }
else if(n==2){ MyBitmap=LoadBitmap(g_hInst,MAKEINTRESOURCE(IDB_BITMAP4)); n=3; }
else if(n==3){ MyBitmap=LoadBitmap(g_hInst,MAKEINTRESOURCE(IDB_BITMAP5)); n=4; }
else if(n==4){ MyBitmap=LoadBitmap(g_hInst,MAKEINTRESOURCE(IDB_BITMAP6)); n=5; }
else if(n>4 && n<=49){ MyBitmap=LoadBitmap(g_hInst,MAKEINTRESOURCE(IDB_BITMAP1)); n++; if(n==49){n=50;}}
else if(n==50){ MyBitmap=LoadBitmap(g_hInst,MAKEINTRESOURCE(IDB_BITMAP6)); n=51; }
else if(n==51){ MyBitmap=LoadBitmap(g_hInst,MAKEINTRESOURCE(IDB_BITMAP5)); n=52; }
else if(n==52){ MyBitmap=LoadBitmap(g_hInst,MAKEINTRESOURCE(IDB_BITMAP4)); n=53; }
else if(n==53){ MyBitmap=LoadBitmap(g_hInst,MAKEINTRESOURCE(IDB_BITMAP3)); n=54; }
else if(n>53 && n<=100){ MyBitmap=LoadBitmap(g_hInst,MAKEINTRESOURCE(IDB_BITMAP2)); n=101; }
else if(n>100 && n<=130){ MyBitmap=LoadBitmap(g_hInst,MAKEINTRESOURCE(IDB_BITMAP7)); n++; if(n==130){ KillTimer(hWnd,1); r=1; m=1; SetTimer(hWnd,2,100,NULL);}}
OldBitmap=(HBITMAP)SelectObject(MemDC,MyBitmap);
BitBlt(hdc,250,200,252,92,MemDC,0,0,SRCCOPY);
SelectObject(MemDC,OldBitmap);
EndPaint(hWnd,&ps);
DeleteObject(MyBitmap);
DeleteDC(MemDC);
}
if(maini==0 && n>-21 && n<=-1 || maini==0 && n>100 && n<=130){ hdc=BeginPaint(hWnd,&ps); MyBrush=(HBRUSH)GetStockObject(BLACK_BRUSH); OldBrush=(HBRUSH)SelectObject(hdc,MyBrush); SelectObject(hdc,MyBrush); Rectangle(hdc,0,0,800,600); DeleteObject(MyBrush); MemDC=CreateCompatibleDC(hdc);
MyBitmap=LoadBitmap(g_hInst,MAKEINTRESOURCE(IDB_BITMAP7)); OldBitmap=(HBITMAP)SelectObject(MemDC,MyBitmap); BitBlt(hdc,250,200,252,92,MemDC,0,0,SRCCOPY); SelectObject(MemDC,OldBitmap);
DeleteObject(MyBitmap); DeleteDC(MemDC); }
if(r==0){
if(n==0 || n>53 && n<=100){ hdc=BeginPaint(hWnd,&ps); MyBrush=(HBRUSH)GetStockObject(BLACK_BRUSH); OldBrush=(HBRUSH)SelectObject(hdc,MyBrush); Rectangle(hdc,0,0,800,600); SelectObject(hdc,OldBrush); DeleteObject(MyBrush); MemDC=CreateCompatibleDC(hdc);
MyBitmap=LoadBitmap(g_hInst,MAKEINTRESOURCE(IDB_BITMAP2)); OldBitmap=(HBITMAP)SelectObject(MemDC,MyBitmap); BitBlt(hdc,250,200,252,92,MemDC,0,0,SRCCOPY); SelectObject(MemDC,OldBitmap);
DeleteObject(MyBitmap); DeleteDC(MemDC); }
else if(n==1 || n==53){ hdc=BeginPaint(hWnd,&ps); MyBrush=(HBRUSH)GetStockObject(BLACK_BRUSH); OldBrush=(HBRUSH)SelectObject(hdc,MyBrush); Rectangle(hdc,0,0,800,600); SelectObject(hdc,OldBrush); DeleteObject(MyBrush); MemDC=CreateCompatibleDC(hdc);
MyBitmap=LoadBitmap(g_hInst,MAKEINTRESOURCE(IDB_BITMAP3)); OldBitmap=(HBITMAP)SelectObject(MemDC,MyBitmap); BitBlt(hdc,250,200,252,92,MemDC,0,0,SRCCOPY); SelectObject(MemDC,OldBitmap);
DeleteObject(MyBitmap); DeleteDC(MemDC); }
else if(n==2 || n==52){ hdc=BeginPaint(hWnd,&ps); MyBrush=(HBRUSH)GetStockObject(BLACK_BRUSH); OldBrush=(HBRUSH)SelectObject(hdc,MyBrush); Rectangle(hdc,0,0,800,600); SelectObject(hdc,OldBrush); DeleteObject(MyBrush); MemDC=CreateCompatibleDC(hdc);
MyBitmap=LoadBitmap(g_hInst,MAKEINTRESOURCE(IDB_BITMAP4)); OldBitmap=(HBITMAP)SelectObject(MemDC,MyBitmap); BitBlt(hdc,250,200,252,92,MemDC,0,0,SRCCOPY); SelectObject(MemDC,OldBitmap);
DeleteObject(MyBitmap); DeleteDC(MemDC); }
else if(n==3 || n==51){ hdc=BeginPaint(hWnd,&ps); MyBrush=(HBRUSH)GetStockObject(BLACK_BRUSH); OldBrush=(HBRUSH)SelectObject(hdc,MyBrush); Rectangle(hdc,0,0,800,600); SelectObject(hdc,OldBrush); DeleteObject(MyBrush); MemDC=CreateCompatibleDC(hdc);
MyBitmap=LoadBitmap(g_hInst,MAKEINTRESOURCE(IDB_BITMAP5)); OldBitmap=(HBITMAP)SelectObject(MemDC,MyBitmap); BitBlt(hdc,250,200,252,92,MemDC,0,0,SRCCOPY); SelectObject(MemDC,OldBitmap);
DeleteObject(MyBitmap); DeleteDC(MemDC); }
else if(n==4 || n==50){ hdc=BeginPaint(hWnd,&ps); MyBrush=(HBRUSH)GetStockObject(BLACK_BRUSH); OldBrush=(HBRUSH)SelectObject(hdc,MyBrush); Rectangle(hdc,0,0,800,600); SelectObject(hdc,OldBrush); DeleteObject(MyBrush); MemDC=CreateCompatibleDC(hdc);
MyBitmap=LoadBitmap(g_hInst,MAKEINTRESOURCE(IDB_BITMAP6)); OldBitmap=(HBITMAP)SelectObject(MemDC,MyBitmap); BitBlt(hdc,250,200,252,92,MemDC,0,0,SRCCOPY); SelectObject(MemDC,OldBitmap);
DeleteObject(MyBitmap); DeleteDC(MemDC); }
else if(n>4 && n<=49){ hdc=BeginPaint(hWnd,&ps); MyBrush=(HBRUSH)GetStockObject(BLACK_BRUSH); OldBrush=(HBRUSH)SelectObject(hdc,MyBrush); Rectangle(hdc,0,0,800,600); SelectObject(hdc,OldBrush); DeleteObject(MyBrush); MemDC=CreateCompatibleDC(hdc);
MyBitmap=LoadBitmap(g_hInst,MAKEINTRESOURCE(IDB_BITMAP1)); OldBitmap=(HBITMAP)SelectObject(MemDC,MyBitmap); BitBlt(hdc,250,200,252,92,MemDC,0,0,SRCCOPY); SelectObject(MemDC,OldBitmap);
DeleteObject(MyBitmap); DeleteDC(MemDC); }
}
else if(maini==1){
if(n==0){n=1; hdc=BeginPaint(hWnd,&ps); MemDC=CreateCompatibleDC(hdc);
MyBitmap=LoadBitmap(g_hInst,MAKEINTRESOURCE(IDB_BITMAP8)); OldBitmap=(HBITMAP)SelectObject(MemDC,MyBitmap); BitBlt(hdc,0,0,800,600,MemDC,0,0,SRCCOPY); SelectObject(MemDC,OldBitmap);
DeleteObject(MyBitmap); DeleteDC(MemDC); }
else if(n==1){n=0; hdc=BeginPaint(hWnd,&ps); MemDC=CreateCompatibleDC(hdc);
MyBitmap=LoadBitmap(g_hInst,MAKEINTRESOURCE(IDB_BITMAP9)); OldBitmap=(HBITMAP)SelectObject(MemDC,MyBitmap); BitBlt(hdc,0,0,800,600,MemDC,0,0,SRCCOPY); SelectObject(MemDC,OldBitmap);
DeleteObject(MyBitmap); DeleteDC(MemDC);} }
if(maini==3 && r==3){
old=1;
SetTimer(hWnd,3,1000,NULL);
HDC hdcs,MemDCs;
hdcs=GetDC(hWnd);
HBITMAP MyBitmaps,OldBitmaps;
HBRUSH MyBrushs,OldBrushs;
MemDCs=CreateCompatibleDC(hdcs);
MyBrushs=(HBRUSH)GetStockObject(WHITE_BRUSH);
OldBrushs=(HBRUSH)SelectObject(hdcs,MyBrushs);
MyBitmaps=LoadBitmap(g_hInst,MAKEINTRESOURCE(IDB_BITMAP10));
OldBitmaps=(HBITMAP)SelectObject(MemDCs,MyBitmaps);
BitBlt(hdcs,655,15,125,125,MemDCs,0,0,SRCCOPY);
SelectObject(MemDCs,OldBitmaps);
ReleaseDC(hWnd,hdcs);
DeleteObject(MyBitmaps);
DeleteDC(MemDCs);
hdc=BeginPaint(hWnd, &ps);
DrawScreen(hWnd,hdc); }
return 0;
case WM_KEYDOWN:
switch(wParam)
{
if(maini==1 && r==3){
case VK_SPACE:
hdc=BeginPaint(hWnd,&ps);
MyBrush=(HBRUSH)GetStockObject(WHITE_BRUSH);
OldBrush=(HBRUSH)SelectObject(hdc,MyBrush);
DeleteObject(OldBrush);
EndPaint(hWnd,&ps);
maini=3;
}
else if(maini==3)
{
case VK_ESCAPE:
if(MessageBox(hWnd,TEXT("종료하시겠습니까?"),TEXT("종료알림창"),MB_YESNO)==IDYES)
{
DestroyWindow(hWnd);
break;
} else { break; }
case 'Z':
Undo();
break;
case VK_LEFT:
case VK_RIGHT:
case VK_UP:
case VK_DOWN:
Move(wParam);
if(TestEnd()){
wsprintf(Message,TEXT("%d 스테이지를 풀었습니다.")
TEXT("다음 스테이지로 이동합니다"),stage+1);
MessageBox(hWnd,Message,TEXT("알림"),MB_OK);
if(stage<LSTAGE-1){
stage++;
}
else if(stage==LSTAGE-1){ wsprintf(Message,TEXT("스테이지를 전부풀었습니다.")
TEXT("게임을 종료합니다."));
MessageBox(hWnd,Message,TEXT("알림"),MB_OK);
DestroyWindow(hWnd);
}
lnitStage();
}
break;
case 'Q':
DestroyWindow(hWnd);
break;
case 'R':
lnitStage();
break;
case 's':
break;
}
}
return 0;
case WM_TIMER:
if(r==0 || r==3){InvalidateRect(hWnd,NULL,FALSE);}
if(r==1 && m==1){ n=0; maini=1; r=3; SetTimer(hWnd,1,500,NULL); InvalidateRect(hWnd,NULL,TRUE); KillTimer(hWnd,2); PlaySound(MAKEINTRESOURCE(IDR_WAVE1),g_hInst,SND_RESOURCE| SND_ASYNC | SND_LOOP); }
if(wParam==4){
KillTimer(hWnd,4);
if(Manbit==4){Manbit=0;}
else if(Manbit==5){Manbit=1;}
else if(Manbit==6){Manbit=2;}
else if(Manbit==7){Manbit=3;}
}
return 0;
case WM_COMMAND:
switch(LOWORD(wParam)){
case ID_MENUITEM40003:
if(MessageBox(hWnd,TEXT("종료하시겠습니까?"),TEXT("종료알림창"),MB_YESNO)==IDYES)
{
DestroyWindow(hWnd);
break;
} else { break; }
case ID_MENUITEM40001:
if(MessageBox(hWnd,TEXT("게임설명을 보시겠습니까?"),TEXT("게임방법창"),MB_YESNO|MB_ICONINFORMATION)==IDYES)
{ DialogBox(g_hInst,MAKEINTRESOURCE(IDD_DIALOG1),hWnd,AboutDlgProc);
return 0;}
else{ break; }
case ID_MENUITEM40004:
MessageBox(hWnd,TEXT("http://ncmweb.new21.org"),TEXT("포트폴리오"),MB_OK);
break;
case ID_MENUITEM40005:
MessageBox(hWnd,TEXT("http://cyworld.nate.com/01096150517"),TEXT("미니홈"),MB_OK);
break;
case ID_MENUITEM40006:
MessageBox(hWnd,TEXT("버디:베너광고/MSN&네이트온:ncmreader@empal.com"),TEXT("메신저"),MB_OK);
break;
}
return 0;
case WM_DESTROY:
DeleteObject(gmaps[0]);
DeleteObject(gmaps[1]);
DeleteObject(gmaps[2]);
DeleteObject(gmaps[3]);
//케릭터 데이터 초기화
DeleteObject(hman[0]);
DeleteObject(hman[1]);
DeleteObject(hman[2]);
MessageBox(hWnd,TEXT("게임을 종료합니다."),TEXT("종료메시지 안내"),MB_OK|MB_ICONINFORMATION);
PostQuitMessage(0);
return 0;
}
return(DefWindowProc(hWnd,iMessage,wParam,lParam));
}
void DrawScreen(HWND hWnd,HDC hdc)
{
//1벽돌/0길/3사람/45678아픈사람/9병원/E입원
int x,y;
int reBit;
TCHAR Message[256];
SYSTEMTIME st;
GetLocalTime(&st);
static TCHAR sTime[128];
for (y=0; y<BY; y++){
for (x=0; x<BX-1; x++){
switch (ns[y][x]){
case '1':
reBit=0;
break;
case '0':
reBit=1;
break;
case '4':
reBit=5;
break;
case '5':
reBit=6;
break;
case '6':
reBit=7;
break;
case '7':
reBit=8;
break;
case '8':
reBit=9;
break;
case '9':
reBit=2;
break;
case 'E':
reBit=3;
break;
}
DrawBitmap(hdc,x*MX,y*MY,gmaps[reBit]);
}
}
DrawBitmaps(hdc,nx*MX,ny*MY,hman[Manbit]);
SetTimer(hWnd,4,300,NULL);
wsprintf(Message,TEXT("병원놀이"));
TextOut(hdc,655,160,Message,lstrlen(Message));
wsprintf(Message,TEXT("스테이지 : %d"),stage+1);
TextOut(hdc,655,190,Message,lstrlen(Message));
wsprintf(Message,TEXT("이동횟수 : %d"),nMove);
TextOut(hdc,655,210,Message,lstrlen(Message));
wsprintf(Message,TEXT("Z.이전"));
TextOut(hdc,655,230,Message,lstrlen(Message));
wsprintf(Message,TEXT("다시"));
TextOut(hdc,655,250,Message,lstrlen(Message));
wsprintf(Message,TEXT("ESC.종료"));
TextOut(hdc,655,250,Message,lstrlen(Message));
wsprintf(Message,TEXT("현재시간"));
TextOut(hdc,655,480,Message,lstrlen(Message));
wsprintf(sTime,TEXT("%d시 %d분 %d초"),st.wHour,st.wMinute,st.wSecond);
TextOut(hdc,655,500,sTime,lstrlen(sTime));
}
BOOL TestEnd()
{
int x,y;
for(y=0;y<BY;y++){
for(x=0;x<BX;x++){
if(nStage[stage][y][x]=='9' && ns[y][x]!='E'){
return FALSE;
}
}
}
return TRUE;
}
void Move(int dir)
{
int dx=0,dy=0;
BOOL bWithPack=FALSE;
int i;
int items;
int x,y;
switch(dir){
case VK_LEFT:
Manbit=4;
dx=-1;
break;
case VK_RIGHT:
Manbit=5;
dx=1;
break;
case VK_UP:
Manbit=6;
dy=-1;
break;
case VK_DOWN:
Manbit=7;
dy=1;
break;
}
if(ns[ny+dy][nx+dx]!='1'){
if(ns[ny+dy][nx+dx]=='4'){
if(ns[ny+dy*2][nx+dx*2]=='0' || ns[ny+dy*2][nx+dx*2]=='9'){
if(nStage[stage][ny+dy][nx+dx]=='9'){
ErasePack(nx+dx,ny+dy);
}else{
ns[ny+dy][nx+dx]='0';
}
ns[ny+dy*2][nx+dx*2]='4';
bWithPack=TRUE;
items=4;
}
else{
return;
}
}
else if(ns[ny+dy][nx+dx]=='5'){
if(ns[ny+dy*2][nx+dx*2]=='0' || ns[ny+dy*2][nx+dx*2]=='9'){
ns[ny+dy][nx+dx]='9';
}else{
ns[ny+dy][nx+dx]='0';
}
ns[ny+dy*2][nx+dx*2]='5';
bWithPack=TRUE;
items=5;
}
else{
return;
}
}
else if(ns[ny+dy][nx+dx]=='6'){
if(ns[ny+dy*2][nx+dx*2]=='0' || ns[ny+dy*2][nx+dx*2]=='9'){
if(nStage[stage][ny+dy][nx+dx]=='9'){
}else{
ns[ny+dy][nx+dx]='0';
}
ns[ny+dy*2][nx+dx*2]='6';
bWithPack=TRUE;
items=6;
}
else{
return;
}
}
else if(ns[ny+dy][nx+dx]=='7'){
if(ns[ny+dy*2][nx+dx*2]=='0' || ns[ny+dy*2][nx+dx*2]=='9'){
if(nStage[stage][ny+dy][nx+dx]=='9'){
ErasePack(nx+dx,ny+dy);
ns[ny+dy][nx+dx]='9';
}else{
ns[ny+dy][nx+dx]='0';
}
ns[ny+dy*2][nx+dx*2]='7';
bWithPack=TRUE;
items=7;
}
else{
return;
}
}
else if(ns[ny+dy][nx+dx]=='8'){
if(ns[ny+dy*2][nx+dx*2]=='0' || ns[ny+dy*2][nx+dx*2]=='9'){
if(nStage[stage][ny+dy][nx+dx]=='9'){
}else{
ns[ny+dy][nx+dx]='0';
}
ns[ny+dy*2][nx+dx*2]='8';
bWithPack=TRUE;
items=8;
}else{
return;
}
}
for(y=0;y<BY;y++){
for(x=0;x<BX;x++){
if(nStage[stage][y][x]=='9' && ns[y][x]=='4'){
ns[y][x]='E';
break;
}
else if(nStage[stage][y][x]=='9' && ns[y][x]=='5'){
ns[y][x]='E';
break;
}
else if(nStage[stage][y][x]=='9' && ns[y][x]=='6'){
ns[y][x]='E';
break;
}
else if(nStage[stage][y][x]=='9' && ns[y][x]=='7'){
ns[y][x]='E';
break;
}
else if(nStage[stage][y][x]=='9' && ns[y][x]=='8'){
ns[y][x]='E';
break;
}
}
}
nx+=dx;
ny+=dy;
nMove++;
MoveInfo[Undoldx].dx=dx;
MoveInfo[Undoldx].dy=dy;
;
MoveInfo[Undoldx].bits=Manbit;
Undoldx++;
MoveInfo[Undoldx].dx=-2;
if(Undoldx==MAXUNDO-1){
for(i=100; i<Undoldx;i++){
MoveInfo[i-100]=MoveInfo[i];
}
for(i=MAXUNDO-100;i<MAXUNDO; i++){
MoveInfo[i].dx=-2;
}
Undoldx-=100;
}
InvalidateRect(hWndMain,NULL,FALSE);
}
}
void ErasePack(int x,int y)
{
if(nStage[stage][y][x]=='9'){
ns[y][x]='9';
}else{
ns[y][x]='0';
}
}
void lnitStage()
{
int x,y;
Manbit=3;
for(x=0; x<MAXUNDO; x++){
MoveInfo[x].dx=-2;
}
memcpy(ns,nStage[stage],sizeof(ns));
for (y=0; y<BY; y++){
for (x=0; x<BX; x++){
if(ns[y][x]=='3'){
nx=x;
ny=y;
ns[y][x]='0';
}
}
}
nMove=0;
InvalidateRect(hWndMain,NULL,TRUE);
}
void DrawBitmap(HDC hdc,int x,int y,HBITMAP gmaps)
{
HDC MemDC;
HBITMAP OldBitmap;
int dx,dy;
BITMAP bit;
dy=bit.bmHeight;
BitBlt(hdc,x,y,dx,dy,MemDC,0,0,SRCCOPY);
SelectObject(MemDC,OldBitmap);
DeleteDC(MemDC);
}
void DrawBitmaps(HDC hdc,int x,int y,HBITMAP gmaps)
{
HDC MemDC;
HBITMAP OldBitmap;
int dx,dy;
BITMAP bit;
MemDC=CreateCompatibleDC(hdc);
OldBitmap=(HBITMAP)SelectObject(MemDC,gmaps);
TransparentBlt(hdc,x,y,dx,dy,MemDC,0,0,dx,dy,RGB(255,255,255));
SelectObject(MemDC,OldBitmap);
DeleteDC(MemDC);
}
void Undo()
{
if(Undoldx !=0){
Undoldx--;
if(MoveInfo[Undoldx].bWithPack){
ErasePack(nx+MoveInfo[Undoldx].dx,ny+MoveInfo[Undoldx].dy);
if(MoveInfo[Undoldx].item==4){ns[ny][nx]='4';}
else if(MoveInfo[Undoldx].item==5){ns[ny][nx]='5';}
else if(MoveInfo[Undoldx].item==8){ns[ny][nx]='8';}
}
nx-=MoveInfo[Undoldx].dx;
Manbit=MoveInfo[Undoldx].bits;
InvalidateRect(hWndMain,NULL,FALSE);
}
}
뭘까?ㅋㄷㅋㄷㅋㄷ