예제 #1
0
bool Piece::isBlocked(string dest, int move[2])
{
    if (m_name=="Knight")
        return false;
    string src = m_position;
    moveOne(src, move);
    for (; src!=dest; moveOne(src, move))
    {
        if (m_pBoard->existPiece(src))
            return true;
    }
    return false;
}
예제 #2
0
void MainWindow::go_right()
{
    QPoint p = que.back();
    p = QPoint(p.x() + 1, p.y());
    moveOne(p);

}
예제 #3
0
// ---
void QGAMES::MovementOneByOne::move (const QGAMES::Vector& d, const QGAMES::Vector& a, 
		QGAMES::Entity* e)
{
	if (!e -> canMove (d, a))
	{
		moveOne (QGAMES::Vector::_cero, 
			QGAMES::Vector::_cero, e); // Stops...
		return;
	}

	// The ways the pacman entity moves, depends 
	// whether the speed is greater or less than the base speed...
	// If greater...
	if (_speed >= _baseSpeed)
	{
		// Moves x times points the speed...
		// As it is possible to move more than one pixel in this loop
		// It is necessary to control the entity can move more than one
		// or it must stop because it reaches
		bool contMove = true;
		for (_counterTSpeed = (int) (_speed / _baseSpeed); 
			_counterTSpeed > 0 && contMove; _counterTSpeed--)
		{
			moveOne (d, a, e); // Any time, it moves only one...
			if (!e -> canMove (d, a))
				contMove = false;
		}

		// Has it to continue moving...
		if (!contMove)
			return; // no...

		// If something rests...
		// Takes into account two decimals...
		// When the entity passes throught this point
		// it can only move one pixel more maximum...
		if ((_speed % _baseSpeed) != 0)
		{
			if (_counterMSpeed[0]++ == (int) ((_baseSpeed / (_speed % _baseSpeed))))
			{
				_counterMSpeed[0] = 0;
				if ((_baseSpeed % (_speed % _baseSpeed)) != 0)
				{
					if (_counterMSpeed[1]++ == 
						((_speed % _baseSpeed) / (_baseSpeed % (_speed % _baseSpeed))))
						_counterMSpeed[1] = 0;
					else
						moveOne (d, a, e); // Any time, it moves only one...
				}
			}
			else
				moveOne (d, a, e); // Any time, it moves only one...
		}
	}

	// If less...
	// In all the situations the entity moves here
	// it moves only one pixel...
	else
	{
		if (_counterMSpeed[0]++ == (int) ((_baseSpeed / (_speed % _baseSpeed))))
		{
			_counterMSpeed[0] = 0;
			moveOne (d, a, e); // Any time it moves only one...
			if ((_baseSpeed % (_speed % _baseSpeed)) != 0)
			{
				if (_counterMSpeed[1]++ < 
					((_speed % _baseSpeed) / (_baseSpeed % (_speed % _baseSpeed))))
					moveOne (d, a, e); // Any time, it moves only one...
				else
					_counterMSpeed[1] = 0;
			}
		}
	}
}
예제 #4
0
// ---
void PacmanEntityMovement::move (const QGAMES::Vector& d, const QGAMES::Vector& a, 
		QGAMES::Entity* e)
{
	// The ways the pacman entity moves, depends 
	// whether the speed is greater or less than the base speed...
	int vel = _speed * _accelerated;

	// If greater...
	if (vel >= __BASESPEED)
	{
		// Moves x times points the speed...
		// As it is possible to move more than one pixel in this loop
		// It is necessary to control the entity can move more than one
		// or it must stop because it reaches
		bool contMove = true;
		for (_counterTSpeed = (int) (vel / __BASESPEED); 
			_counterTSpeed > 0 && contMove; _counterTSpeed--)
		{
			moveOne (d, a, e); // Any time, it moves only one...
			if (!((PacmanArtist*) e) -> continueMoving ())
				contMove = false;
		}

		// Has it to continue moving...
		if (!contMove)
			return; // no...

		// If something rests...
		// Takes into account two decimals...
		// When the monster passes throught this point
		// it can only move one pixel more maximum...
		if ((vel % __BASESPEED) != 0)
		{
			if (_counterMSpeed[0]++ == (int) ((__BASESPEED / (vel % __BASESPEED))))
			{
				_counterMSpeed[0] = 0;
				if ((__BASESPEED % (vel % __BASESPEED)) != 0)
				{
					if (_counterMSpeed[1]++ == 
						((vel % __BASESPEED) / (__BASESPEED % (vel % __BASESPEED))))
						_counterMSpeed[1] = 0;
					else
						moveOne (d, a, e);
				}
			}
			else
				moveOne (d, a, e); // Any time, it moves only one...
		}
	}

	// If less...
	// In all the situations the monsters moves here
	// it moves only one pixel...
	else
	{
		if (_counterMSpeed[0]++ == (int) ((__BASESPEED / (vel % __BASESPEED))))
		{
			_counterMSpeed[0] = 0;
			moveOne (d, a, e); // Any time it moves only one...
			if ((__BASESPEED % (vel % __BASESPEED)) != 0)
			{
				if (_counterMSpeed[1]++ < 
					((vel % __BASESPEED) / (__BASESPEED % (vel % __BASESPEED))))
					moveOne (d, a, e); // Any time, it moves only one...
				else
					_counterMSpeed[1] = 0;
			}
		}
	}
}
예제 #5
0
// move one servo to an angle between -160 and 160
void HerkulexClass::moveOneAngle(int servoID, float angle, int pTime, int iLed) {
	if (angle > 160.0|| angle < -160.0) return;	
	int position = (int)(angle/0.325) + 512;
	moveOne(servoID, position, pTime, iLed);
}
예제 #6
0
void MainWindow::go_down()
{
    QPoint p = que.back();
    p = QPoint(p.x(), p.y() + 1);
    moveOne(p);
}
예제 #7
0
void MainWindow::go_left()
{
    QPoint p = que.back();
    p = QPoint(p.x() - 1, p.y());
    moveOne(p);
}