Esempio n. 1
0
void Map::get_map_items_by_coordinates(int x, int y, std::list<MapItem*>* out_list)
{
	if (this->_map_items == nullptr || this->_map_items->size() == 0)
	{
		//return nullptr; -> nothing
	}
	else
	{
		for (std::list<MapItem*>::iterator iterator = this->_map_items->begin(), end = this->_map_items->end(); iterator != end; ++iterator)
		{
			MapItem* it = *iterator;
			Vec* position = it->get_position();
			if (position->get_x() == x && position->get_y() == y)
				out_list->push_back(it);
		}
	}
}
Esempio n. 2
0
MapItem* Map::get_map_item_by_coordinates(int x, int y) const
{
	if (this->_map_items == nullptr || this->_map_items->size() == 0)
	{
		return nullptr;
	}
	else
	{
		for (std::list<MapItem*>::iterator iterator = this->_map_items->begin(), end = this->_map_items->end(); iterator != end; ++iterator)
		{
			MapItem* it = *iterator;

			Vec* position = it->get_position();
			if (position->get_x() == x && position->get_y() == y)
				return it;
		}
		return nullptr;
	}
}