• 大小: 1.13MB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2023-09-02
  • 语言: 其他
  • 标签: VC  迷宫  windows  api  

资源简介

运用了广度优先设计了走迷宫的算法,图形化界面,通过鼠标在迷宫内设置障碍,然后可以显示迷宫的一条最短的路径!

资源截图

代码片段和文件信息

#include 
#include
const int MAX_COW=50MAX_COL=50;
int row=6col=6;
int Num_Point=-1;
HWND hwndEdit1hwndEdit2hwndButton1hwndButton2;
typedef int a[3];
a b[2];
struct newtype
{
int i;
int j;
}path[400];
LRESULT CALLBACK WndProc(HWNDUINTWPARAMLPARAM); 
bool check(int iint jint a[MAX_COW][MAX_COL]);
bool Labyrinth(int a[MAX_COW][MAX_COL]);

int WINAPI WinMain(HINSTANCE hInstanceHINSTANCE hPrevInstLPSTR lpszCmdLineint nCmdShow)
{
HWND hwnd ;
MSG Msg ;
WNDCLASS wndclass ;
char lpszClassName[] = “窗口“;
char lpsztitle[]= “走迷宫“;


wndclass.style = 0;
wndclass.lpfnWndProc = WndProc ;
wndclass.cbClsExtra = 0 ;
wndclass.cbWndExtra = 0 ;
wndclass.hInstance = hInstance ;
wndclass.hIcon = LoadIcon(hInstance“IDI_ICON“) ;

wndclass.hCursor = LoadCursor( NULLIDC_ARROW); 
wndclass.hbrBackground =(HBRUSH) GetStockobject(WHITE_BRUSH); 
wndclass.lpszMenuName = NULL ;
wndclass.lpszClassName = lpszClassName; 


if( !RegisterClass( &wndclass))
{
MessageBeep(0) ;
return FALSE ;
}


hwnd=CreateWindow(
lpszClassName
lpsztitle
WS_OVERLAPPEDWINDOW
CW_USEDEFAULT
CW_USEDEFAULT
500
550
NULL
NULL
hInstance
NULL) ;


ShowWindow( hwnd SW_SHOW); 
UpdateWindow(hwnd); 
while( GetMessage(&Msg NULL 0 0))
{
TranslateMessage( &Msg) ;
DispatchMessage( &Msg) ;
}
return Msg.wParam;
}


LRESULT CALLBACK WndProc(HWND hwndUINT messageWPARAM  wParamLPARAM lParam)
{
HDC hdc;
PAINTSTRUCT ps;
HBRUSH hB;
char str[20];
int T=1;
HFONT hF;
HPEN hP;
POINT origintemp;
static int Mg[MAX_COW][MAX_COL];
static POINT Mouse;
static int Num=0;
const char title[10]=“迷宫游戏“;
const char instruction[50]=“使用说明:鼠标在迷宫里面某个格子内点击一下表示“;
const char instruction2[60]=“设置障碍再点击一下可以取消障碍。“;
const char instruction3[50]=“(注意:行列都不能超过50)“;
int hight=240/rowwidth=240/colijmFlag_BrushFlag;
origin.x=130;
origin.y=130;

switch(message)
{
case WM_CREATE:
hwndEdit1 = CreateWindow(“EDIT“      
                                    NULL        
                                    WS_CHILD | WS_VISIBLE  |ES_NUMBER | ES_LEFT
                                    | ES_MULTILINE | ES_AUTOVSCROLL 
                                    180100 20 20 
                                    hwnd       
                                    NULL  
                                    NULL 
                                    NULL);      
hwndEdit2= CreateWindow(“EDIT“     
                                    NULL        
                                    WS_CHILD | WS_VISIBLE  |ES_NUMBER | ES_LEFT
                                    | ES_MULTILINE | ES_AUTOVSCROLL 
                                    250 100 20 20  
                                    hwnd       
                                    NULL  
            

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

    .CA....       876  2007-12-30 11:17  labyrinth\Debug\ico.res

    .CA....    163889  2008-01-05 14:21  labyrinth\Debug\labyrinth.exe

    .CA....    279356  2008-01-05 14:21  labyrinth\Debug\labyrinth.ilk

    .CA....     27283  2008-01-05 14:21  labyrinth\Debug\labyrinth.obj

    .CA....   3553308  2008-01-05 14:10  labyrinth\Debug\labyrinth.pch

    .CA....    443392  2008-01-05 14:21  labyrinth\Debug\labyrinth.pdb

    .CA....    140288  2008-01-05 14:27  labyrinth\Debug\vc60.idb

    .CA....     77824  2008-01-05 14:21  labyrinth\Debug\vc60.pdb

    .CA....     17628  2007-12-27 20:26  labyrinth\ico.aps

    .CA....      1721  2007-12-27 19:30  labyrinth\ico.rc

    .CA....       766  2007-12-27 19:56  labyrinth\icon1.ico

    .CA....      8229  2008-01-05 14:21  labyrinth\labyrinth.cpp

    .CA....      4075  2007-12-27 19:37  labyrinth\labyrinth.dsp

    .CA....       541  2007-12-24 15:28  labyrinth\labyrinth.dsw

    .CA....     50176  2008-01-05 14:38  labyrinth\labyrinth.ncb

    .CA....     53760  2008-01-05 14:38  labyrinth\labyrinth.opt

    .CA....       252  2008-01-05 14:27  labyrinth\labyrinth.plg

    .CA....     32208  2007-12-27 19:59  labyrinth\mg.aps

    .CA....      1721  2007-12-27 19:59  labyrinth\mg.ico

    .CA....       860  2007-12-27 19:58  labyrinth\mg.res

    .CA....       452  2007-12-27 19:58  labyrinth\resource.h

    .CA....      1721  2007-12-27 19:47  labyrinth\script1.rc

    .C.D...         0  2008-01-05 14:21  labyrinth\Debug

    .C.D...         0  2008-01-05 14:38  labyrinth

----------- ---------  ---------- -----  ----

              4860326                    24


评论

共有 条评论