⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cell.cpp

📁 简单实现了A*寻路算法
💻 CPP
字号:
// Cell.cpp: implementation of the CCell class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "test.h"
#include "Cell.h"


#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CCell::CCell()
{
	px=py=0;
	f=g=h=0;
	pParent=NULL;
}

CCell::CCell(int x,int y)
{
	px=x;
	py=y;	
	pParent=NULL;
}

CCell::~CCell()
{
	
}

void CCell::ComputeGHF()
{
	/*int x,y;
	x=abs(px-pParent->px);
	y=abs(py-pParent->py);*/

	int xa,ya;//npow;
	xa=abs(px-pParent->px)*10;
	ya=abs(py-pParent->py)*10;	
	
	if (xa==10 && ya==10)
		g=14+pParent->g;
	else
		g=10+pParent->g;
	f=g+h;
	return;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -