예제 #1
0
void testMovement()
{
	int time = 0;
	int speed = 0;
	int test = 0;
	while(true)
	{
		test = random(5);
		speed = random(100);
		time = random(20);

		switch(test){
			case 1:
				MoveForward(time,speed); break;
			case 2:
				MoveBackwards(time,speed); break;
			case 3:
				TurnLeft(time,speed); break;
			case 4:
				TurnRight(time,speed); break;
			case 5:
				Stop(time); break;
			default:
				break;
		}
	}
}
예제 #2
0
/*!
	Initialize the camera position.
 */
Camera::Camera(std::string name, Scene* parent, CameraType camType) : Object(name, parent)
{
    // INITIALIZE PARAMETERS
    Reset();
    
    //SET THE TYPE OF CAMERA
    type            = camType;
    
    if(parent){
        parent->addCamera(this);
    }
    
    MoveBackwards(20.0);
    StrafeUpside(5.0);
    glEnable(GL_SCISSOR_TEST);
}
void PlayerCamera::UpdateCamera(float inTimeDelta)
{

	D3DXMatrixRotationY(&tmpMat, (_pInput->_mouseState).lX / 300.0f);
	D3DXVec3TransformCoord(&_right, &_right, &tmpMat);
	D3DXVec3TransformCoord(&_look3, &_look3, &tmpMat);

	D3DXMatrixRotationAxis(&tmpMat, &_right, (_pInput->_mouseState).lY / 300.0f);
	D3DXVec3TransformCoord(&_up, &_up, &tmpMat);
	D3DXVec3TransformCoord(&_look3, &_look3, &tmpMat);


	if( _pInput->IsWPressed() )
	{
		MoveForwards(inTimeDelta);
	}

	if( _pInput->IsSPressed() )
	{
		MoveBackwards(inTimeDelta);
	}

	if( _pInput->IsAPressed() )
	{
		StrafeLeft(inTimeDelta);
	}

	if( _pInput->IsDPressed() )
	{
		StrafeRight(inTimeDelta);
	}

	_position4.x = _position3.x;
	_position4.y = _position3.y;
	_position4.z = _position3.z;
	_position4.w = 1.0f;

	_look4.x = _look3.x;
	_look4.y = _look3.y;
	_look4.z = _look3.z;
	_look4.w = 1.0f;

	UpdateViewMatrix();

	D3DXMatrixMultiply(&_viewProjectionMatrix , &_viewMatrix, &_projectionMatrix);
}
예제 #4
0
task main()
{
	//waitForStart();
	LineUp();
	/*Tests*/
	GoToIR();
	bool LightGoDown = false;
	if(SensorValue[Sensei] == 1)
	{
		LightGoDown = true;
	}
	MoveBackwards(0.1,50);
	while(LightGoDown)
	{
		LineDown();
		FollowLine();
		if(AtObject())
		{
			break;
		}
	}
	LineUp();
	//testMovement();
}
void ControllerComponent::Update(double dt, GridMap * currMap)
{
	m_dInputDelay += dt;
	m_dMoveDelay += dt;

	EntityTest * thePlayer = dynamic_cast<EntityTest*>(this->getParent());
	auto infoC = this->getParent()->getComponent<InformationComponent>();
	if (infoC)
	{
		// CONTROL PLAYER
		if (!this->m_sMovement.m_bIsMoving)
		{

			if (m_dMoveDelay > MOVEMENT_DELAY)
			{
				if (m_cInputHandler->IsKeyPressed(GLFW_KEY_UP))
				{
					MoveForward(currMap);
				}
				else if (m_cInputHandler->IsKeyPressed(GLFW_KEY_LEFT))
				{
					MoveLeft(currMap);
				}
				else if (m_cInputHandler->IsKeyPressed(GLFW_KEY_DOWN))
				{
					MoveBackwards(currMap);
				}
				else if (m_cInputHandler->IsKeyPressed(GLFW_KEY_RIGHT))
				{
					MoveRight(currMap);
				}
			}

			if (m_dInputDelay > INTERACTION_DELAY)
			{
				if (m_cInputHandler->IsKeyPressed(GLFW_KEY_E))
				{
					Interact(currMap);
				}
			}
		}
		else
		{
			float newX, newY;
			int absX, absY;
			Vector3 prevPosition = infoC->getPosition();
			switch (this->m_sMovement.m_eMoveDirection)
			{
			case GridMap::DIRECTION_UP: // X does not Change
				newY = Math::SmoothDamp(infoC->getPosition().y, this->m_sMovement.m_v3NextPosition.y, 4096.f, 0.001f, 4096.f, dt);
				infoC->setPosition(Vector3(prevPosition.x, newY, 0.f));
				absY = (int)newY;
				if (m_sMovement.m_v3NextPosition.y == absY)
				{
					m_sMovement.m_bIsMoving = false;
					currMap->getGridMap()[m_sMovement.m_iPlayerIndexY - 1][m_sMovement.m_iPlayerIndexX]->addGridEntity(currMap->getGridMap()[m_sMovement.m_iPlayerIndexY][m_sMovement.m_iPlayerIndexX]->getGridEntity());
					currMap->getGridMap()[m_sMovement.m_iPlayerIndexY][m_sMovement.m_iPlayerIndexX]->removeEntity();
				}
				break;
			case GridMap::DIRECTION_DOWN: // X does not Change
				newY = Math::SmoothDamp(infoC->getPosition().y, this->m_sMovement.m_v3NextPosition.y, 4096.f, 0.001f, 4096.f, dt);
				infoC->setPosition(Vector3(prevPosition.x, newY, 0.f));
				absY = (int)newY;
				if (m_sMovement.m_v3NextPosition.y == absY)
				{
					m_sMovement.m_bIsMoving = false;
					currMap->getGridMap()[m_sMovement.m_iPlayerIndexY + 1][m_sMovement.m_iPlayerIndexX]->addGridEntity(currMap->getGridMap()[m_sMovement.m_iPlayerIndexY][m_sMovement.m_iPlayerIndexX]->getGridEntity());
					currMap->getGridMap()[m_sMovement.m_iPlayerIndexY][m_sMovement.m_iPlayerIndexX]->removeEntity();
				}
				break;
			case GridMap::DIRECTION_LEFT: // Y does not Change
				newX = Math::SmoothDamp(infoC->getPosition().x, this->m_sMovement.m_v3NextPosition.x, 4096.f, 0.001f, 4096.f, dt);
				infoC->setPosition(Vector3(newX, prevPosition.y, 0.f));
				absX = (int)newX;
				if (m_sMovement.m_v3NextPosition.x == absX)
				{
					m_sMovement.m_bIsMoving = false;
					currMap->getGridMap()[m_sMovement.m_iPlayerIndexY][m_sMovement.m_iPlayerIndexX - 1]->addGridEntity(currMap->getGridMap()[m_sMovement.m_iPlayerIndexY][m_sMovement.m_iPlayerIndexX]->getGridEntity());
					currMap->getGridMap()[m_sMovement.m_iPlayerIndexY][m_sMovement.m_iPlayerIndexX]->removeEntity();
				}
				break;
			case GridMap::DIRECTION_RIGHT: // Y does not Change
				newX = Math::SmoothDamp(infoC->getPosition().x, this->m_sMovement.m_v3NextPosition.x, 4096.f, 0.001f, 4096.f, dt);
				infoC->setPosition(Vector3(newX, prevPosition.y, 0.f));
				absX = (int)newX;
				if (m_sMovement.m_v3NextPosition.x == absX)
				{
					m_sMovement.m_bIsMoving = false;
					currMap->getGridMap()[m_sMovement.m_iPlayerIndexY][m_sMovement.m_iPlayerIndexX + 1]->addGridEntity(currMap->getGridMap()[m_sMovement.m_iPlayerIndexY][m_sMovement.m_iPlayerIndexX]->getGridEntity());
					currMap->getGridMap()[m_sMovement.m_iPlayerIndexY][m_sMovement.m_iPlayerIndexX]->removeEntity();
				}
				break;
			}
		}
	}
}