bool MovingEffect::moveStep() {
	if(isMoving() && !move_path.empty()){
		loc = move_path.back();
		move_path.pop_back();
		return true;
	}
	stopMove();
	return false;
}
Ejemplo n.º 2
0
/**
* @brief Process the last input stored
*
* This function executes the last input stored by the function receiveInput
*
* @See receiveInput()
*/
void Object::executeLastInput()
{
	char direction;
	unsigned char personDirection, state, ticks;

	state = getState();
	ticks = stats->ss.ticks;
	
	direction = directionFromInput(lastInput);
	personDirection = getDirection(state);

	addTicks();

	if(wasHitted(state))
	{
		if(stats->ss.ticks >= stats->ss.hittedTicks)
		{
			changeState(state & 0x07);
			zeroTicks();
		}
		breakMovement();
	}
	else if(isMeleeAttacking(state))
	{
		if(stats->ss.ticks >= stats->ss.meleeTicks)
		{
			changeState(state & 0x07);
			stats->ss.ticks = 0;
		}
		breakMovement();
	}
	else if(isBreaking(state))
	{
		if(stats->ps->dx == 0 && stats->ps->dy == 0)
		{
			changeState(state & 0x07);
		}
		breakMovement();
	}
	else if(isMoving(state))
	{
		if(direction == -3)
		{
			changeState(0x80 | personDirection);
		}
		else
		{
			movement(personDirection);
		}
	}
	else
	{
		breakMovement();
	}
	lastInput = 0;
}
Ejemplo n.º 3
0
void AMCompositeControl::onChildControlMovingChanged()
{
	bool nowMoving = isMoving();

	if(wasMoving_ && !nowMoving)
		emit movingChanged(wasMoving_ = nowMoving);

	if(!wasMoving_ && nowMoving)
		emit movingChanged(wasMoving_ = nowMoving);
}
Ejemplo n.º 4
0
//jumble/randomize letters in top array
//If too few letters, exit
//If jumbled word matches original, loop again
//If loop again > 5 times, then exit - failsafe
bool Roundels::jumbleWord(bool bAnimate /*=true*/)
{
	if (isMoving()) return false;

	int xx = 0;		//pos to swap...
	int xx2 = 0;	//...with this pos
	Roundel *rtmp;

	//count letters in top array
	int n = 0;
	tRoundVect::iterator it;
	for (it = _top.begin(); it != _top.end(); ++it) if ((*it)) n++;
	if (n < 3) return false;	//dont bother jumbling, not enough letters

	int loops = 6;	//failsafe to exit after 5 retries,in case XXXXXX or other silly found
	do
	{
		xx=0;	//keep a position count in the vector as we access it using [xx]
		for (xx = 0; xx < (int)_top.size(); ++xx)
		{
			//dont swap blank spaces or letters currently moving up or down
			if (!(_top[xx]) || _top[xx]->_spr->isMoving()) continue;

			do
			{	//rand another letter position                  
				xx2 = (rand()%_top.size());	//0..5
				//xx2 = ((int)_gd._myrand.Random(6));	//0..5
			} while (xx2 == xx || !(_top[xx2]));

			//swap the actual pointers to the roundels 
			//(makes it easier all round rather than trying to sort/determine positions)
			rtmp = _top[xx2];
			_top[xx2] = _top[xx];
			_top[xx] = rtmp;
			//now swap positioins
			_top[xx]->_pos = xx;
			_top[xx2]->_pos = xx2;
		}
		if (!isInOrder()) break;	//not spelling original word so ok, exit loop
	} while (loops--);	//check loops THEN decrement (as 'loops' can be set to 0 to exit)

	//recalc screen positions now letter positions have been jumbled
	for (it = _top.begin(); it != _top.end(); ++it)
	{
		if (*it && !(*it)->_spr->isMoving())
		{
			if (bAnimate) 
				(*it)->_spr->startMoveTo(calcXPos((*it)), calcYPos((*it)), 25, 0, 9, 0);	//start slide anim
			else
				recalcXYPosition((*it));
		}
	}
	return true;
}
void BoardActor::moveStep(){
	if(isMoving()){
		if(move_path.empty()){
			stopMove();
			return;
		}
		screen_location = move_path.back();
		location = Util::screenToCoord(screen_location);
		move_path.pop_back();
	}
}
Ejemplo n.º 6
0
void CharacterBall::computePosition(){
    if (!isMoving()){
        if (_jitter > 0){
            sprite -> setPosition( _jitterPos );
        }else{
            sprite -> setPosition( floatingPos );
        }
    }else{
        sprite -> setPosition( Vec2::ZERO );
    }
}
Ejemplo n.º 7
0
// Start a move to the value setpoint:
AMControl::FailureExplanation CLSMDriveMotorControl::move(double Setpoint) {

    if(isMoving()) {
        if(!allowsMovesWhileMoving()) {
            AMErrorMon::debug(this, AMPVCONTROL_COULD_NOT_MOVE_WHILE_MOVING, QString("AMPVControl: Could not move %1 (%2) to %3, because the control is already moving.").arg(name()).arg(writePV_->pvName()).arg(setpoint_));
            return AlreadyMovingFailure;
        }

        if(!moveInProgress()) {
            // the control is already moving, but it's not one of our moves. In this situation, there is no way that we can start a move and be assured that we'll be notified when OUR move finishes.
            AMErrorMon::debug(this, AMPVCONTROL_COULD_NOT_MOVE_WHILE_MOVING_EXTERNAL, QString("AMPVControl: Could not move %1 (%2) to %3, because the control is already moving.").arg(name()).arg(writePV_->pvName()).arg(setpoint_));
            return AlreadyMovingFailure;
        }

        // Otherwise: This control supports mid-move updates, and we're already moving. We just need to update the setpoint and send it.
        setpoint_ = writeUnitConverter()->convertToRaw(Setpoint);
        writePV_->setValue(setpoint_);
        // since the settling phase is considered part of a move, it's OK to be here while settling... But for Acquaman purposes, this will be considered a single re-targetted move, even though the hardware will see two.  If we're settling, disable the settling timer, because we only want to respond to the end of the second move.
        if(settlingInProgress_) {
            settlingInProgress_ = false;
            settlingTimer_.stop();
        }
        emit moveReTargetted(); // re-targetted moves will emit moveReTargetted(), although no moveSucceeded()/moveFailed() will be issued for the initial move.
    }

    else {
        settlingInProgress_ = false;
        stopInProgress_ = false;
        moveInProgress_ = false;
        // Flag that "our" move started:
        startInProgress_ = true;

        // This is our new target:
        setpoint_ = writeUnitConverter()->convertToRaw(Setpoint);

        // Special case: "null move" should complete immediately. Use only if moveStartTolerance() is non-zero, and the move distance is within moveStartTolerance().
        if(moveStartTolerance() != 0 && fabs(setpoint()-value()) < moveStartTolerance()) {
            startInProgress_ = false;
            moveInProgress_ = true;
            emit moveStarted();
            moveInProgress_ = false;
            emit moveSucceeded();
        }
        // Normal move:
        else {
            // Issue the move command:
            writePV_->setValue(setpoint_);
            // start the timer to check if our move failed to start:
            moveStartTimer_.start(int(moveStartTimeout_*1000.0));
        }
    }

    return NoFailure;
}
Ejemplo n.º 8
0
// Update touch
static void touch_update(int id, float x, float y)
{
	if (isMoving(id, x, y)) {
		D("touch_update: id=" << id << ", x=" << x << ", y=" << y);
		lastX[id] = x;
		lastY[id] = y;

		TUIO::TuioCursor* cursor = cursors[id];
		server->updateTuioCursor(cursor, x, y);
	}
}
Ejemplo n.º 9
0
boolean Controller::runWithBlocking()
{
  leftEdge = digitalRead(LEFT_END);
  rightEdge = digitalRead(RIGHT_END);
  leftBtn = digitalRead(LEFT_BTN);
  rightBtn = digitalRead(RIGHT_BTN);
  
  if (left)
  {
    if (leftEdge && millis() < endTime)
    {
      digitalWrite(MOVE_LEFT, HIGH);
    }
    else if (!leftBtn || !leftEdge) // if button isn't still pressed or has reached the end
    {
      digitalWrite(MOVE_LEFT, LOW);
      left = false;
      //eventTime = millis() - eventTime;
    }
  }
  else if (right)
  { 
    if (rightEdge && millis() < endTime)
    {
      digitalWrite(MOVE_RIGHT, HIGH);
    }
    else if (!rightBtn || !rightEdge) // if button isn't still pressed or has reached the end
    {
      digitalWrite(MOVE_RIGHT, LOW);
      right = false;
      //eventTime = millis() - eventTime;
    }
  }
  /*else if (eventTime != 0)
  {
    Log.Debug("Last action time: %d ms", eventTime);
    eventTime = 0;
  }*/
  else
  {
    if (leftBtn)
    {
      Log.Debug("Left button pressed");
      moveLeft(25);
    }
    else if (rightBtn)
    {
      Log.Debug("Right button pressed");
      moveRight(25);
    }
  }
  return isMoving()/* && eventTime == 0*/;
}
void AM3DCoordinatedSystemControl::updateMoving()
{
	if(globalXAxis_ && globalYAxis_ && globalZAxis_) {
		bool isNowMoving = false;

		isNowMoving |= (globalXAxis_->isMoving() && affectedByMotionsInX());
		isNowMoving |= (globalYAxis_->isMoving() && affectedByMotionsInY());
		isNowMoving |= (globalZAxis_->isMoving() && affectedByMotionsInZ());

		if(isNowMoving != isMoving()) {
			setIsMoving(isNowMoving);
		}
	}
}
Ejemplo n.º 11
0
bool Board::fireBrick(Grid location, Brick* nextBrick, zf::Direction direction)
{
    if(isMoving())
    {
        return false;
    }
    Grid directionGrid = Grid(0,0);
    switch(direction)
    {
        case zf::North:
            directionGrid = Grid(-1,0);
            break;
        case zf::South:
            directionGrid = Grid(1,0);
            break;
        case zf::East:
            directionGrid = Grid(0,1);
            break;
        case zf::West:
            directionGrid = Grid(0,-1);
            break;
    }
    Grid nextGrid = location + directionGrid;
    Brick* brick = getBrickAt(nextGrid.row , nextGrid.col);
    if(brick != 0)
    {
        return false; // if there is a brick blocking directly, don't allow it to shoot.
    }
    //find the first block that it will hit
    // move nextGrid back first
    nextGrid -= directionGrid;
    while(brick == 0)
    {
        nextGrid += directionGrid;
        Grid temp = nextGrid + directionGrid;
        if(!inShootableRange(temp.row,temp.col)) // if the next is not in shootable range , break
        {
            // prevent out of bound
            break;
        }
        brick = getBrickAt(temp.row, temp.col);
    }

    _knock = -1;
    putBrickInto(location.row,location.col,nextBrick);
    nextBrick->moveToLocation(nextGrid.row, nextGrid.col);
    _currentMovingDirection = directionGrid; 
    _movingBricks.push_back(nextBrick);
    return true;
}
Ejemplo n.º 12
0
int getAngles(data_t accel_data, data_t gyro_data, data_t zero_rate, float *pitch_angle, float *roll_angle, float *yaw_angle)
{
    float accel_data_z;
    float accel_data_x;
    float accel_data_y;
    float gyro_data_x, gyro_rate_x;
    float gyro_data_y, gyro_rate_y;
    float gyro_data_z, gyro_rate_z;
    float gain = 90.0/65.0;
    
    accel_data_z = accel_data.z;
    if (accel_data_z > 1)
        accel_data_z = 1;
    if (accel_data_z < -1)
        accel_data_z = -1;
    
    accel_data_y = accel_data.y - 0.075;
    if (accel_data_y > 1)
        accel_data_y = 1;
    if (accel_data_y < -1)
        accel_data_y = -1;
    
    accel_data_x = accel_data.x + 0.085;
    if (accel_data_x > 1)
        accel_data_x = 1;
    if (accel_data_x < -1)
        accel_data_x = -1;
       
    *pitch_angle = acos(accel_data_y/-1)*180/M_PI-90.0;
    *roll_angle = acos(accel_data_x/-1)*180/M_PI-90.0;

	if (isMoving(gyro_data)==0)
	{
		gyro_rate_x = 0;
		gyro_rate_y = 0;
		gyro_rate_z = 0;
	}
	else
	{
		gyro_data_z = gyro_data.z;
		
		gyro_rate_z = (gyro_data_z - zero_rate.z)*gain;

	}
	
    *yaw_angle += gyro_rate_z*0.1;
    printf("yaw angle: %f ", *yaw_angle);
    return 0;
}
Ejemplo n.º 13
0
void RayTracedTechnique::cull(osgUtil::CullVisitor* cv)
{
    if (!_transform.valid()) return;

    if (_whenMovingStateSet.valid() && isMoving(cv))
    {
        cv->pushStateSet(_whenMovingStateSet.get());
        _transform->accept(*cv);
        cv->popStateSet();
    }
    else
    {
        _transform->accept(*cv);
    }
}
Ejemplo n.º 14
0
void MapTilesFrame::mouseMoveEvent(QMouseEvent *event)
{
    if (isMoving())
    {
        //当下面的计数器达到一定次数时,才响应一次鼠标移动事件
        ++timeToGo;
        if(timeToGo >= 5)
        {
            timeToGo = 0;

            setViewportCoordinate(getViewportCoordinate() - QPoint(event->x(), this->height() - event->y()) + dragPosition);
            //move(event->globalPos() - dragPosition);
            event->accept();
        }
    }
}
Ejemplo n.º 15
0
void SGMHexapodTransformedAxis::updateMoving()
{
    if(globalXAxis_ && globalYAxis_ && globalZAxis_ &&
            globalXAxisFeedback_ && globalYAxisFeedback_ && globalZAxisFeedback_) {
        bool isNowMoving = false;

        isNowMoving |= (globalXAxisFeedback_->isMoving() && affectedByMotionsInX());
        isNowMoving |= (globalYAxisFeedback_->isMoving() && affectedByMotionsInY());
        isNowMoving |= (globalZAxisFeedback_->isMoving() && affectedByMotionsInZ());


        if(isNowMoving != isMoving()) {
            setIsMoving(isNowMoving);
        }
    }
}
Ejemplo n.º 16
0
//unjumble/unrandomize letters in top array
//If too few letters, exit
//Only used in main menu screen on REWORD letters above the menu.
//NOTE: if it is used elsewhere, we may need to protect it aainst rogue letter stray 
//		like the jumbleWord fn where ismoving() needed to be checked
bool Roundels::unJumbleWord(bool bAnimate /*=true*/)
{
	if (isMoving()) return false;

	int xx = 0;		//pos to swap...
	int xx2 = 0;	//...with this pos
	Roundel *rtmp;

	//count letters in top array
	int n = 0;
	tRoundVect::iterator it;
	for (it = _top.begin(); it != _top.end(); ++it) if ((*it)) n++;
	if (n < 3) return false;	//dont bother jumbling, not enough letters

	for (xx=0; xx<(int)_word.length(); ++xx)
	{
		if (_top[xx]->_letter == _word[xx]) continue;		//already matches
		
		//find a match for curr letter in remaining letters
		for (xx2=xx+1; xx2<(int)_word.length(); ++xx2)
		{
			if (_top[xx2]->_letter == _word[xx])
			{
				//swap xx and xx2
				rtmp = _top[xx];
				_top[xx] = _top[xx2];
				_top[xx2] = rtmp;
				//now swap positioins
				_top[xx]->_pos = xx;
				_top[xx2]->_pos = xx2;
			}
		}
	}

	//recalc screen positions now letter positions have been jumbled
	for (it = _top.begin(); it != _top.end(); ++it)
	{
		if (*it)
		{
			if (bAnimate) 
				(*it)->_spr->startMoveTo(calcXPos((*it)), calcYPos((*it)), 25, 0, 9, 0);	//start slide anim
			else
				recalcXYPosition((*it));
		}
	}
	return true;
}
void QBlockDiagramLinkEnd::paint( QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget /*= 0 */ )
{
    painter->setPen(m_pOwnerLink->m_Pens[m_pOwnerLink->dominantPenState()]);
    painter->setBrush(m_pOwnerLink->m_Brushes[m_pOwnerLink->dominantBrushState()]);
    painter->drawEllipse(boundingRect());
    if(getConnectedSlot() && !isMoving() && !getTwin()->isMoving())
    {
        if(getConnectedSlot()->getConnectionCount() > 1 && !getConnectedSlot()->areConnectionNodesExpanded())
        {
            QFont f = painter->font();
            f.setPointSize(7);
            f.setWeight(99);
            painter->setFont(f);
            painter->drawText(boundingRect(), Qt::AlignCenter, QString::number(getConnectedSlot()->getConnectionCount()));
        }
    }
}
Ejemplo n.º 18
0
void Ball::update(float delta){
    if (isMoving()){
        //air resistance
        auto velocity = body -> getVelocity();
        auto length = velocity.length();
        if (length < VELOCITY_DUMP){
            body -> setVelocity( Vec2::ZERO );
        }else{
            auto dir = Vec2(velocity);
            dir.normalize();
            body -> setVelocity( velocity - (length * delta * AIR_RESISTANCE) * dir );
        }
    }
    //floating
    floatingPos = sin(ScreenUtil::getTime() * 3.0f + randomSeed * 3.14f) * Vec2(0 , 3);
    
    computePosition();
}
Ejemplo n.º 19
0
//move the letters currently on the bottom row back
//to the top, to the gaps already there
void Roundels::clearAllToTop(bool bResetCursor /*=true*/)
{
	if (isMoving()) return;	//can't move if any already moving

	//make sure players cursor is on top line
	_bCursorTop = true;
	if (bResetCursor) cursorFirst();	

	int xx = 0;
	//move letters in bottom row to gaps in top 
	for (xx=0; xx < (int)_word.length(); ++xx)
	{
		if (_bot[xx] == 0) return; 	//no more in bottom row

		_cx = xx;
		moveLetterUp();
	}
}
Ejemplo n.º 20
0
/**
* @brief Stores and partially treats the input
*
* This function treats the input coming from the user. Note that the events are treated to
* generate the inputs. The parameter is not a raw character. The character type is only used to
* use 8 bit storage.
*
* @param input An unsigned char representing the input
*/
void Object::receiveInput(unsigned char input)
{
	char direction;
	unsigned char personDirection, state;

	state = getState();

	direction = directionFromInput(input);
	personDirection = getDirection(state);

	if(isNotBusy())
	{
		lastInput = input;
		if(meleeAttackFromInput(input))
		{
			if(direction == -3)
			{
				changeState(0x10 | personDirection);
			}
			else
			{
				changeState(0x10 | direction);
			}
			zeroTicks();
		}
		else if(!isBreaking(state))
		{
			if(direction != -3)
			{
				if(isMoving(state)
					&& direction != ((personDirection) & 0x07)
					&& direction != ((personDirection + 1) & 0x07)
					&& direction != ((personDirection - 1) & 0x07))
				{
					changeState(0x80 | direction);
				}
				else
				{
					changeState(0x08 | direction);
				}
			}
		}
	}
}
Ejemplo n.º 21
0
    void Paddle::updatePosition(double deltaTime) {
        if(isMoving()) {
            switch(getDirection()) {
                case Model::Direction::Left:
                    _position.x -= static_cast<float>(_speedFactor * deltaTime);
                    if(_position.x < _positionRange.x)
                        _position.x = _positionRange.x;

                    break;

                case Model::Direction::Right:
                    _position.x += static_cast<float>(_speedFactor * deltaTime);
                    if(_position.x > _positionRange.y)
                        _position.x = _positionRange.y;

                    break;
            }
        }
    }
Ejemplo n.º 22
0
void ASIEAF::TimerHit()
{
    if (!isConnected())
    {
        SetTimer(POLLMS);
        return;
    }

    bool rc = readPosition();
    if (rc)
    {
        if (fabs(lastPos - FocusAbsPosN[0].value) > 5)
        {
            IDSetNumber(&FocusAbsPosNP, nullptr);
            lastPos = FocusAbsPosN[0].value;
        }
    }

    rc = readTemperature();
    if (rc)
    {
        if (fabs(lastTemperature - TemperatureN[0].value) >= 0.1)
        {
            IDSetNumber(&TemperatureNP, nullptr);
            lastTemperature = TemperatureN[0].value;
        }
    }

    if (FocusAbsPosNP.s == IPS_BUSY || FocusRelPosNP.s == IPS_BUSY)
    {
        if (!isMoving())
        {
            FocusAbsPosNP.s = IPS_OK;
            FocusRelPosNP.s = IPS_OK;
            IDSetNumber(&FocusAbsPosNP, nullptr);
            IDSetNumber(&FocusRelPosNP, nullptr);
            lastPos = FocusAbsPosN[0].value;
            LOG_INFO("Focuser reached requested position.");
        }
    }

    SetTimer(POLLMS);
}
Ejemplo n.º 23
0
void Player::updateSpeed(const sf::Time& elapsed_time)
{
    // Update speed
    if( isMoving() )
    {
        if(isMaxSpeedReached())
            return;

        // Speed gain depending on elapsed time
        float speed_gain = elapsed_time.asMilliseconds() * _acceleration;

        // Moving to left means minus speed
        if( _moving_to_direction == Direction::Left )
            speed_gain = -speed_gain;

        // Update speed
        _horizontal_speed += speed_gain;

        // Respect max speed
        if( std::abs(_horizontal_speed) > _max_speed )
            _horizontal_speed = ( _moving_to_direction == Direction::Left ) ? -_max_speed : _max_speed;
    }
    // Not moving, but remaining inertia
    else if( _horizontal_speed != 0.f )
    {
        // Speed loss depending on elapsed time
        float speed_loss = elapsed_time.asMilliseconds() * _deceleration;

        if( _horizontal_speed > 0.f )
        {
            _horizontal_speed -= speed_loss;
            if(_horizontal_speed < 0.f)
                _horizontal_speed = 0.f;
        }
        else if( _horizontal_speed < 0.f )
        {
            _horizontal_speed += speed_loss;
            if(_horizontal_speed > 0.f)
                _horizontal_speed = 0.f;
        }
    }
}
Ejemplo n.º 24
0
    void FirstPersonNavigation::keyEvent(tgt::KeyEvent* keyEve){
        if (keyEve->pressed()){
            if (keyMoveForward_ == keyEve->keyCode()){
                firstMove_ = !isMoving();
                movingDirection_.z = 1;
            }
            else if (keyMoveBackward_ == keyEve->keyCode()){
                firstMove_ = !isMoving();
                movingDirection_.z = -1;
            }
            else if (keyMoveLeft_ == keyEve->keyCode()){
                firstMove_ = !isMoving();
                movingDirection_.x = 1;
            }
            else if (keyMoveRight_ == keyEve->keyCode()){
                firstMove_ = !isMoving();
                movingDirection_.x = -1;
            }
            else if (keyMoveDown_ == keyEve->keyCode()){
                firstMove_ = !isMoving();
                movingDirection_.y = 1;
            }
            else if (keyMoveUp_ == keyEve->keyCode()){
                firstMove_ = !isMoving();
                movingDirection_.y = -1;
            }

            move();
        }
        else {
            if (keyMoveForward_ == keyEve->keyCode() || keyMoveBackward_ == keyEve->keyCode())
                movingDirection_.z = 0;
            else if (keyMoveRight_ == keyEve->keyCode() || keyMoveLeft_ == keyEve->keyCode())
                movingDirection_.x = 0;
            else if (keyMoveUp_ == keyEve->keyCode() || keyMoveDown_ == keyEve->keyCode())
                movingDirection_.y = 0;

            if (!isMoving()){
                curAccuteness_ = minAccuteness_;
                stopwatch_->stop();
                firstMove_ = true;
            }
        }
    }
Ejemplo n.º 25
0
void StepperController::moveTo(int32_t x,int32_t y,int32_t z,int32_t feedRate)
{
	
	uint32_t moveTime;
	uint8_t i;
	
	for (i=0;i<3;i++)
	{
		steppers[i].targetStep = x;
		int32_t deltaSteps = x - steppers[i].currentStep;
		steppers[i].bDirectionPositive = deltaSteps >= 0;
		steppers[i].deltaSteps = ABS(deltaSteps);

		if (steppers[i].deltaSteps > 0)
		{
			PORTP(steppers[i].enPort) |= steppers[i].enPin;
			
			if (steppers[i].bDirectionPositive)
				PORTP(steppers[i].dirPort) |= steppers[i].dirPin;
			else
				PORTP(steppers[i].dirPort) &= ~steppers[i].dirPin;
				
		}
		moveTime = MAX(moveTime,steppers[i].deltaSteps / feedRate);
	}
	
	for (i=0;i<3;i++)
	{
		if (steppers[i].deltaSteps > 0)
		{
			steppers[i].stepDelay = STEPPER_HZ / (steppers[i].deltaSteps / moveTime);
			steppers[i].currentStepTime = steppers[i].stepDelay;
		}
	}
	
	mbMoving = isMoving();
	
	if (mbMoving)
		timer.enable();
		
}
Ejemplo n.º 26
0
void StepperController::update()
{
	if (mbMoving)
	{
#ifdef STEPPERX_DISABLE_INACTIVE
		if (!steppers[0].deltaSteps)
			PORTP(steppers[0].enPort) &= ~steppers[0].enPin;
#endif
#ifdef STEPPERY_DISABLE_INACTIVE
		if (!steppers[1].deltaSteps)
			PORTP(steppers[1].enPort) &= ~steppers[1].enPin;
#endif
#ifdef STEPPERZ_DISABLE_INACTIVE
		if (!steppers[2].deltaSteps)
			PORTP(steppers[2].enPort) &= ~steppers[2].enPin;
#endif

		mbMoving = isMoving();
		if (!mbMoving)
			timer.disable();
	}
}
Ejemplo n.º 27
0
//redisplay (as selected tiles) the last word that was tried
//Allows player to quickly redo a word and add or remove a letter at the end
void Roundels::setWordToLast()
{
	if (isMoving()) return;	//can't move if any already moving

	int oldcx = _cx;
	clearAllToTop(false);
	int xtop = 0;
	int xlast = 0;
	for (xlast=0; xlast < (int)_word.length(); ++xlast)
	{
		if (0 == _last[xlast]) break;	//no more letters in last[] array
		for (xtop=0; xtop < (int)_word.length(); ++xtop)
		{
			if (_top[xtop] == _last[xlast])
			{
				_cx = xtop;
				moveLetterDown();
				break;
			}
		}
	}
	_cx = oldcx;
}
Ejemplo n.º 28
0
void moveTest(void){
	if(isMoving() == 0 ){
		int *motion = motionList[motionNumber];
		int max = motion[0];
		if( motionCount > max ){
			walkCounter++;
			if (walkCounter < 10) {
				printf("### moveTest 1\n");
				motionNumber = ACT_TURN_LEFT;
			} else if (walkCounter < 20) {
				printf("### moveTest 2\n");
				motionNumber = ACT_TURN_RIGHT;
			} else if (walkCounter < 30) {
				printf("### moveTest 3\n");
				motionNumber = ACT_WALK2;
			} else {
				walkCounter=0;
			}
			motionCount = 1;
		}
		ServoControl( motion[motionCount] );
		motionCount++;
	}
}
Ejemplo n.º 29
0
    int Analysis::inWhichAreaIsMoving(IplImage* curr, IplImage* prev, Presentation* prs) {
        int area;

        CvPoint point[] = {prs->leftUL, prs->img1UL, prs->img2UL, prs->img3UL, prs->rightUL};
        int width[] = {prs->leftBR.x - prs->leftUL.x, prs->img1BR.x - prs->img1UL.x,
            prs->img2BR.x - prs->img2UL.x, prs->img3BR.x - prs->img3UL.x, prs->rightBR.x - prs->rightUL.x};
        int height[] = {prs->leftBR.y - prs->leftUL.y, prs->img1BR.y - prs->img1UL.y,
            prs->img2BR.y - prs->img2UL.y, prs->img3BR.y - prs->img3UL.y, prs->rightBR.y - prs->rightUL.y};

        for (int i = 0; i < 5; i++) {
            cvSetImageROI(curr, cvRect(point[i].x, point[i].y, width[i], height[i]));
            cvSetImageROI(prev, cvRect(point[i].x, point[i].y, width[i], height[i]));
            IplImage* diff = Analysis::getDiff(curr, prev);
            cvResetImageROI(curr);
            cvResetImageROI(prev);
            if (isMoving(diff)) {
                cvReleaseImage(&diff);
                return area = i;
            }
            cvReleaseImage(&diff);
        }

        return -1;
    }
Ejemplo n.º 30
0
void RayModel::computeBoundingTree(int maxDepth)
{
    CubeModel* cubeModel = createPrevious<CubeModel>();

    if (!isMoving() && !cubeModel->empty()) return; // No need to recompute BBox if immobile

    Vector3 minElem, maxElem;

    cubeModel->resize(size);
    if (!empty())
    {
        for (int i=0; i<size; i++)
        {
            Ray r(this, i);
            const Vector3& o = r.origin();
            const Vector3& d = r.direction();
            const SReal l = r.l();
            for (int c=0; c<3; c++)
            {
                if (d[c]<0)
                {
                    minElem[c] = o[c] + d[c]*l;
                    maxElem[c] = o[c];
                }
                else
                {
                    minElem[c] = o[c];
                    maxElem[c] = o[c] + d[c]*l;
                }
            }
            cubeModel->setParentOf(i, minElem, maxElem);
        }
        cubeModel->computeBoundingTree(maxDepth);
    }

}