cell.cpp

来自「简单实现了A*寻路算法」· C++ 代码 · 共 56 行

CPP
56
字号
// 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 + =
减小字号Ctrl + -
显示快捷键?