Esempio n. 1
0
void Enemy1::moveToPosition(int X, int Y)
{
	diffrenceY = abs(Y+mHigth - getBottomY());
	diffrenceX = abs(posX_ - X);
	if (diffrenceY >screenH_ * DIFF_BY_Y_PERCENTIGE)
	{
		if (Y > posY_)
		{
			if (moveDir.down)
			{
				moveDown();
				action = true;
				return;
			}

		}
		else if (Y <posY_)
		{
			if (moveDir.up)
			{
				moveUp();
				action = true;
				return;
			}
		}
	}
	else if (diffrenceX >screenW_ * DIFF_BY_X_PERCENTIGE)
	{
		if (posX_ > X)
		{
			if (moveDir.left)
			{
				moveLeft();
				action = true;
				return;
			}
		}
		else if (posX_ < X)
		{
			if (moveDir.right)
			{
				moveRight();
				action = true;
				return;
			}
		}
	}
	if (diffrenceY < screenH_ * DIFF_BY_Y_PERCENTIGE+5)
	{
		posX_ =X;
		action = true;
	}
	if (diffrenceX < screenW_ * DIFF_BY_X_PERCENTIGE)
	{
		posY_ = Y;
		action = true;
	}
}
Esempio n. 2
0
bool Square::isContainingPoint(int x, int y) const {

	int leftX = getLeftX();
	int rightX = getRightX();
	int topY = getTopY();
	int bottomY = getBottomY();

	if (x <= rightX && x >= leftX)
		if (y <= bottomY && y >= topY)
			return true;

	return false;
}
Esempio n. 3
0
bool Square::isContainingPoint(const Point& otherPoint) const {
	
	int leftX = getLeftX();
	int rightX = getRightX();
	int topY = getTopY();
	int bottomY = getBottomY();

	// compare the otherPoint coordinate with the current shape boundaries
	if (otherPoint.getX() <= rightX && otherPoint.getX() >= leftX)
		if (otherPoint.getY() <= bottomY && otherPoint.getY() >= topY)
			return true;
	
	return false;
}