Пример #1
0
	//-------------------------------------------------
	void RTSCamera::onMouseButtonDown( NamedProperties& params )
	{
		int keyCode;
		vec2i mouseCoords;
		
		if( params.get( "keyCode", keyCode ) == NamedProperties::SUCCESS )
		{
			if( keyCode == GLUT_MIDDLE_BUTTON )
			{
				if( params.get( "screenCoords", mouseCoords ) == NamedProperties::SUCCESS )
					m_lastDragPos = mouseCoords;
								
				m_isDragging = true;
			}
		}
	}
Пример #2
0
	//-------------------------------------------------
	void RTSCamera::onSpecialKeyUp( NamedProperties& params )
	{
		int keyCode;
		if( params.get( "keyCode", keyCode ) == NamedProperties::SUCCESS )
		{
			m_activeSpecialKeys[ keyCode ] = false;
		}
	}
Пример #3
0
	//-------------------------------------------------
	void RTSCamera::onMouseButtonUp( NamedProperties& params )
	{
		int keyCode;
		if( params.get( "keyCode", keyCode ) == NamedProperties::SUCCESS )
		{
			if( keyCode == GLUT_MIDDLE_BUTTON )
				m_isDragging = false;
		}
	}
Пример #4
0
	//-------------------------------------------------------------------
	void AttackMoveOrders::entityKilled( NamedProperties& params )
	{
		Entity* entityKilled = nullptr;
		if( params.get( "entity", entityKilled ) == NamedProperties::SUCCESS )
		{
			if( entityKilled == m_currentTargetEntity )
			{
				m_currentTargetEntity = nullptr;
			}
		}
	}
Пример #5
0
	//----------------------------------------------------------------------
	void PlayerController::shipDiedEvt( NamedProperties& params )
	{
		Spaceship* tempShip;
		if( params.get( "spaceship", tempShip ) == NamedProperties::SUCCESS )
		{
			if( tempShip == m_ship )
			{
				m_shipRespawnTimer->start();
				m_ship = nullptr;
			}
		}
	}
Пример #6
0
	//-------------------------------------------------
	void RTSCamera::onMouseMove( NamedProperties& params )
	{
		vec2i mouseCoords;
		if( m_isDragging )
		{
			if( params.get( "mouseCoords", mouseCoords ) == NamedProperties::SUCCESS )
			{
				vec2i dirMouseSpace = mouseCoords - m_lastDragPos;
				vec2f dir = vec2f( (float)dirMouseSpace.x, (float)dirMouseSpace.y );
				dir.normalize();
				setPosition( getPosition() - dir );
			}
		}
	}
Пример #7
0
	//-------------------------------------------------
	void RTSCamera::onSpecialKeyDown( NamedProperties& params )
	{
		int keyCode;
		if( params.get( "keyCode", keyCode ) == NamedProperties::SUCCESS )
		{
			m_activeSpecialKeys[ keyCode ] = true;
			switch( keyCode ) 
			{
			case GLUT_KEY_LEFT:
				m_impulse.x -= 1.0f;
				break;
			case GLUT_KEY_RIGHT:
				m_impulse.x += 1.0f;
				break;
			case GLUT_KEY_UP:
				m_impulse.y += 1.0f;
				break;
			case GLUT_KEY_DOWN:
				m_impulse.y -= 1.0f;
				break;
			}
		}
	}