示例#1
0
	void UpdateCamera()
	{
		
		CameraFocusRect.width = Camera.width * CameraFocus;
		CameraFocusRect.height = Camera.height * CameraFocus;
		CameraFocusRect.left = ((1 - CameraFocus) * Camera.width) / 2;
		CameraFocusRect.top = ((1 - CameraFocus) * Camera.height) / 2;

		if (!CameraFocusRect.contains(Player1.Center()))
		{
			if (Player1.Center().x < CameraFocusRect.left)
				Camera.left -= CameraFocusRect.left - Player1.Center().x;
			if (Player1.Center().x > (CameraFocusRect.left + CameraFocusRect.width))
				Camera.left += Player1.Center().x - (CameraFocusRect.left + CameraFocusRect.width);
			if (Player1.Center().y < CameraFocusRect.top)
				Camera.top -= CameraFocusRect.top - Player1.Center().y;
			if (Player1.Center().y >(CameraFocusRect.top + CameraFocusRect.height))
				Camera.top += Player1.Center().y - (CameraFocusRect.top + CameraFocusRect.height);
		}

		if (Camera.left < 0)
			Camera.left = 0;
		if (Camera.top < 0)
			Camera.top = 0;
		if ((Camera.left + Camera.width) > (tiles[0].size() * 64))
			Camera.left = (tiles[0].size() * 64) - Camera.width;
		if ((Camera.top + Camera.height) > (tiles[0].size() * 64))
			Camera.top = (tiles[0].size() * 64) - Camera.height;
	}
示例#2
0
bool MouseHandler::IsOver(sf::IntRect rect)
{
	if(rect.contains(MousePosition.x, MousePosition.y)){
		return true;
	}
	else
	{
		return false;
	}
}
///////////////
// INTERSECT //
///////////////
void SelectionController::intersectSelection(const sf::IntRect& rect, const std::vector<nSet::o_line>& conf_l) {
	if (isSelected()) {
		intersectSelection(rect, static_cast<sf::Image*>(NULL));
		setInverted(false);

		pos_lines = new nSet::positionned_olines(*pos_lines);
		FOR_I_INV (pos_lines->lines.size())
			if (!rect.contains(pos_lines->lines[i].x, pos_lines->lines[i].y))
				pos_lines->lines.erase(pos_lines->lines.begin() + i);
		pos_lines->lines.insert(pos_lines->lines.end(), conf_l.begin(), conf_l.end());
		pos_lines->pos = getPosition();
	
		if (!reline()) {
			UNDO->push(*new SelecUpdated(this, *image_selec, pos_lines->pos, *pos_lines, inverted));
			emit selectionUpdated(3);
		}
	}
	else