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

📄 object.cpp

📁 基于SDL的图形化贪心算法演示,支持节点的拖放
💻 CPP
字号:
#include "Object.h"
#include "ShortPath.h"

#include <deque>
using namespace std;

void MapNode::Draw()
{
	static SDL_Surface* text;


	if( m_bFocus )
		g_gui->Blit( g_redcircle, m_x, m_y );
	
	else 
		g_gui->Blit( g_blackcircle, m_x, m_y );

	text = TTF_RenderText_Shaded( g_gui->GetFont(0), m_Text, BLACK, WHITE );

	g_gui->Blit( text, (g_blackcircle->w - text->w) / 2 + m_x,(g_blackcircle->h - text->h) / 2 + m_y );

	SDL_FreeSurface( text );


	for( int i = 0; i< deque_line.size(); ++i )
	{
		deque_line.at(i)->Draw();
	}

}

int MapNode::GetLengthToNode( int index )
{
	MapNode* node = (*p_NodeDeque)[index];

	for( int i = 0; i< deque_line.size(); ++i )
	{

		if( deque_line[i]->GetToNode() == node )
		{
			return deque_line[i]->Legnth();
		}
	}

	return MAX_NUM;
}

⌨️ 快捷键说明

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