void ModelSelectionPane::mouseReleaseEvent(QMouseEvent *mouseEvent)
{
    int elapseTime = m_time.elapsed();
    float acceleration = (mouseEvent->x() - m_touchBeginLastX) / (float)elapseTime;

    bool flip = false;
    FlipDirection direction = acceleration > 0 ? FlipDirection_Left : FlipDirection_Right;
    if( qAbs(acceleration) > 1 || qAbs(mouseEvent->x() - m_touchBeginLastX) > width()/2 ) {
        flip = true;
        if( ((FlipDirection_Left == direction) && (m_curPaneIndex == 0))
                || ((FlipDirection_Right == direction) && (m_curPaneIndex == m_paneIndexCount - 1)) ) {
            flip = false;
        }
    }

    if(flip) {
        FlipAnimationStart(direction);
    } else {
        ResetPostion();
    }
}
예제 #2
0
void ArmClass::Update(float ArmLift, float Shooter, float Turret, bool Ball, bool Reset, bool EnableTracking,float cX,float cY,float calX,float calY)
{
	PreviousEnableTracking = CurrentEnableTracking;
	CurrentEnableTracking = EnableTracking;
	if(CurrentEnableTracking && !PreviousEnableTracking)
	{
		ArmPIDController->Reset();
		TurretPIDController->Reset();
		ArmLockonTimer->Start();
	}
	if(!CurrentEnableTracking && PreviousEnableTracking)
	{
		ArmPIDController->Disable();
		TurretPIDController->Disable();
		ArmLockonTimer->Stop();
		ArmLockonTimer->Reset();
	}
	if(isShooting)
	{
		ArmPIDController->Disable();
		TurretPIDController->Disable();
		ArmPIDController->Reset();
		TurretPIDController->Reset();
	}
	if(CurrentEnableTracking)
	{
		// When auto-aiming, turn on the shooter wheels
		Shooter = 1.0f;

		ArmPIDController->Enable();
		TurretPIDController->Enable();
		if((fabs(LastMoveByDegreesX) > LOCKON_DEGREES_X) || (fabs(LastMoveByDegreesY) > LOCKON_DEGREES_Y))
		{
			ArmLockonTimer->Reset();
		}
		else if((ArmLockonTimer->Get() > LOCKON_SECONDS) && (!isShooting))
		{
			// if the user was holding the shooter wheels on AND we have been locked on,
			// then do a quick auto shot.
			if(Shooter == 1.0f)  // NOTE, we now force Shooter on when auto-aiming (top of this CurrentEnableTracking block)
			{
				if(LastShotTimer->Get() > 1.5f)
				{
					FullShotQuick();
					printf("SHOT!\r\n");
					ArmLockonTimer->Reset();
					LastShotTimer->Reset();
					LastShotTimer->Start();
				}
			}
		}
		else if (Ball)
		{
			FullShotQuick();
			printf("Manual shot during tracking!\r\n");
			ArmLockonTimer->Reset();
		}
		FullShotUpdate();
	}

	//TurretPIDController->SetPID(P*.001f, I*.00001f, 0.0f);

	if(ArmTimer->Get() > .01f)
	{
		HandleTarget(cX,cY,calX,calY);
		ArmTimer->Reset();
		ArmTimer->Start();
	}

	UpdateLift(ArmLift);
	UpdateTurret(Turret);
	if(CurrentResetInput && !PrevResetInput)
	{
		ResetPostion();
	}

	if (!isauto)
	{
		ArmShooter->Set(Shooter);
		ArmShooter2->Set(-Shooter);
	}

	if(!isauto && !CurrentEnableTracking)
	{
		PrevBallTog = CurrentBallTog;
		CurrentBallTog = Ball;

		PrevResetInput = CurrentResetInput;
		CurrentResetInput = Reset;

		if(Ball)
		{
			ShotRetract->Set(false);
			ShotExtend->Set(true);
		}
		else
		{
			ShotRetract->Set(true);
			ShotExtend->Set(false);
		}
	}
}