91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 82KB
    文件類型: .zip
    金幣: 2
    下載: 0 次
    發布日期: 2021-06-08
  • 語言: 其他
  • 標簽: AStar??A*??尋路??

資源簡介

實現了A*尋路算法,用Win32 GDI繪制的圖形界面進行展示。算法部分與界面展示部分進行了良好的分離,便于將算法應用到其它GUI框架上。 程序運行時鼠標左鍵雙擊設定目標點即開始尋路,并將結果動態展示出來。程序設定了全局的定時器,每25毫秒一刷新。 地圖文件為bin\2.map,可自行編輯,0是空地,1表示障礙物。

資源截圖

代碼片段和文件信息

//?AStarPath.cpp?:?定義應用程序的入口點。
//

#include?“stdafx.h“
#include?“AStarPath.h“
#include?“Map.h“
#include?“Gameobject.h“
#include?“PathFinder.h“
#include?“PerformaceTimer.h“

#define?MAX_LOADSTRING?100

//?全局變量:
HINSTANCE?hInst; //?當前實例
TCHAR?sztitle[MAX_LOADSTRING]; //?標題欄文本
TCHAR?szWindowClass[MAX_LOADSTRING]; //?主窗口類名
HWND?g_mainWnd;

//?此代碼模塊中包含的函數的前向聲明:
ATOM MyRegisterClass(HINSTANCE?hInstance);
BOOL InitInstance(HINSTANCE?int);
LRESULT?CALLBACK WndProc(HWND?UINT?WPARAM?LPARAM);
INT_PTR?CALLBACK About(HWND?UINT?WPARAM?LPARAM);

int?cxClient?cyClient;
Map?g_map;
Gameobject?g_object;
int?g_timerID;

void?CALLBACK?Update(HWND?hwnd?UINT?message?UINT?idTimer?DWORD?dwTime)
{
int?ret?=?g_object.Updateobject(?0?);

InvalidateRect(g_mainWnd?NULL?TRUE);
}

int?APIENTRY?_tWinMain(HINSTANCE?hInstance
?????????????????????HINSTANCE?hPrevInstance
?????????????????????LPTSTR????lpCmdLine
?????????????????????int???????nCmdShow)
{
UNREFERENCED_PARAMETER(hPrevInstance);
UNREFERENCED_PARAMETER(lpCmdLine);

? //?TODO:?在此放置代碼。
MSG?msg;
HACCEL?hAccelTable;

//?初始化全局字符串
LoadString(hInstance?IDS_APP_title?sztitle?MAX_LOADSTRING);
LoadString(hInstance?IDC_ASTARPATH?szWindowClass?MAX_LOADSTRING);
MyRegisterClass(hInstance);

//?執行應用程序初始化:
if?(!InitInstance?(hInstance?nCmdShow))
{
return?FALSE;
}

hAccelTable?=?LoadAccelerators(hInstance?MAKEINTRESOURCE(IDC_ASTARPATH));

//?主消息循環:
while?(GetMessage(&msg?NULL?0?0))
{
if?(!TranslateAccelerator(msg.hwnd?hAccelTable?&msg))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}

return?(int)?msg.wParam;
}



//
//??函數:?MyRegisterClass()
//
//??目的:?注冊窗口類。
//
//??注釋:
//
//????僅當希望
//????此代碼與添加到?Windows?95?中的“RegisterClassEx”
//????函數之前的?Win32?系統兼容時,才需要此函數及其用法。調用此函數十分重要,
//????這樣應用程序就可以獲得關聯的
//????“格式正確的”小圖標。
//
ATOM?MyRegisterClass(HINSTANCE?hInstance)
{
WNDCLASSEX?wcex;

wcex.cbSize?=?sizeof(WNDCLASSEX);

wcex.style =?CS_HREDRAW?|?CS_VREDRAW?|?CS_DBLCLKS;
wcex.lpfnWndProc =?WndProc;
wcex.cbClsExtra =?0;
wcex.cbWndExtra =?0;
wcex.hInstance =?hInstance;
wcex.hIcon =?LoadIcon(hInstance?MAKEINTRESOURCE(IDI_ASTARPATH));
wcex.hCursor =?LoadCursor(NULL?IDC_ARROW);
wcex.hbrBackground =?(HBRUSH)(COLOR_WINDOW+1);
wcex.lpszMenuName =?MAKEINTRESOURCE(IDC_ASTARPATH);
wcex.lpszClassName =?szWindowClass;
wcex.hIconSm =?LoadIcon(wcex.hInstance?MAKEINTRESOURCE(IDI_SMALL));

return?RegisterClassEx(&wcex);
}

int?InitGame()
{
char?strFilePath[MAX_PATH];
char*?strLastSlash;
//?Get?the?exe?exe?path
GetModuleFileName(?NULL?strFilePath?MAX_PATH?);
strFilePath[MAX_PATH-1]=0;

strLastSlash?=?_tcsrchr(?strFilePath?TEXT(‘\\‘)?);
if(?strLastSlash?)
{
//?Chop?the?exe?name?from?the?exe?path
*strLastSlash?=?0;
}
strcpy_s(?strLastSlash?7?“\\2.map“?);
g_map.InitMap(?strFilePath?);

g_object.Initobject();


?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2014-09-17?16:46??bin\
?????文件???????16160??2014-09-17?15:25??bin\2.map
?????文件??????109568??2014-09-17?16:27??bin\AStarPath.exe
?????文件??????180224??2014-09-17?16:26??bin\AStarPathd.exe
?????目錄???????????0??2014-09-17?18:37??project\
?????文件?????????884??2014-09-17?15:43??project\AStarPath.sln
?????文件????????5617??2014-09-17?16:27??project\AStarPath.vcxproj
?????文件????????2438??2014-09-17?15:59??project\AStarPath.vcxproj.filters
?????文件?????????143??2014-09-17?15:44??project\AStarPath.vcxproj.user
?????目錄???????????0??2014-09-17?16:46??resource\
?????文件???????23558??2009-08-31?02:31??resource\AStarPath.ico
?????文件????????7412??2014-09-17?15:51??resource\AStarPath.rc
?????文件???????23558??2009-08-31?02:31??resource\small.ico
?????目錄???????????0??2014-09-17?16:46??source\
?????文件????????6912??2014-09-17?16:09??source\AStarPath.cpp
?????文件??????????39??2014-09-14?11:05??source\AStarPath.h
?????文件????????2854??2014-09-17?14:47??source\FFBinaryHeap.h
?????文件????????1782??2014-09-17?14:47??source\FFOpenList.h
?????文件????????2432??2014-09-17?15:21??source\Gameobject.cpp
?????文件?????????560??2014-09-17?15:21??source\Gameobject.h
?????文件????????1888??2014-09-16?12:34??source\Map.cpp
?????文件?????????614??2014-09-16?12:39??source\Map.h
?????文件????????5076??2014-09-17?15:28??source\PathFinder.cpp
?????文件????????1337??2014-09-17?15:28??source\PathFinder.h
?????文件?????????627??2014-09-16?15:31??source\PerformaceTimer.cpp
?????文件?????????303??2014-09-16?15:31??source\PerformaceTimer.h
?????文件????????1998??2014-09-17?15:15??source\resource.h
?????文件?????????214??2014-09-17?15:15??source\stdafx.cpp
?????文件?????????529??2014-09-17?11:01??source\stdafx.h
?????文件?????????236??2014-09-14?11:05??source\targetver.h

評論

共有 條評論