Ejemplo n.º 1
0
void Player::handleEvent(const sf::Event& event, CommandQueue& commands)
{
    // event souris
    if (event.type == sf::Event::KeyPressed)
    {
         auto found = m_keyBinding.find(event.key.code);
            if (found != m_keyBinding.end() && !isRealtimeAction(found->second))
                commands.push(m_actionBinding[found->second]);
    }
    else if(event.type == sf::Event::MouseButtonPressed)
    {
        auto found = m_mouseBinding.find(event.mouseButton.button);
            if (found != m_mouseBinding.end() && !isRealtimeAction(found->second))
                commands.push(m_actionBinding[found->second]);
    }
}
Ejemplo n.º 2
0
void Player::handleRealTimeInput(CommandQueue& commands)
{
    // Traverse all assigned keys and check if they are pressed
    for (auto it = m_keyBinding.begin(); it!= m_keyBinding.end(); ++it)
    {
        // If key is pressed, lookup action and trigger corresponding command
        if (sf::Keyboard::isKeyPressed((*it).first) && isRealtimeAction((*it).second))
            commands.push(m_actionBinding[(*it).second]);
    }

    // Check if mouse button are pressed
    for (auto it = m_mouseBinding.begin(); it!= m_mouseBinding.end(); ++it)
    {
        // If key is pressed, lookup action and trigger corresponding command
        if (sf::Mouse::isButtonPressed((*it).first) && isRealtimeAction((*it).second))
            commands.push(m_actionBinding[(*it).second]);
    }
}
Ejemplo n.º 3
0
Archivo: Player.cpp Proyecto: MVPet/JA
void Player::handleRealtimeInput(CommandQueue& commands)
{
	// Traverse all assigned keys and check if they are pressed
	for (auto pair : mKeyBinding)
	{
		// If key is pressed, lookup action and trigger corresponding command
		if (sf::Keyboard::isKeyPressed(pair.first) && isRealtimeAction(pair.second))
			commands.push(mActionBinding[pair.second]);
	}
}
Ejemplo n.º 4
0
Archivo: Player.cpp Proyecto: MVPet/JA
void Player::handleEvent(const sf::Event& event, CommandQueue& commands)
{
	if (event.type == sf::Event::KeyPressed)
	{
		// Check if pressed key appears in key binding, trigger command if so
		auto found = mKeyBinding.find(event.key.code);
		if (found != mKeyBinding.end() && !isRealtimeAction(found->second))
			commands.push(mActionBinding[found->second]);
	}
}
Ejemplo n.º 5
0
void PlayerController::handleRealtimeInput(CommandQueue &commands)
{
    for(auto pair : mKeyBinding)
    {
        if(sf::Keyboard::isKeyPressed(pair.first) && isRealtimeAction(pair.second))
        {
            commands.push(mActionBinding[pair.second]);
        }
    }
}
Ejemplo n.º 6
0
std::vector<KeyBinding::Action> KeyBinding::getRealtimeActions() const
{
    std::vector<Action> actions;
    
    for (auto pair : mKeyMap)
    {
        if (sf::Keyboard::isKeyPressed(pair.first) && isRealtimeAction(pair.second))
            actions.push_back(pair.second);
    }
    
    return actions;
}
Ejemplo n.º 7
0
std::vector<KeyBinding::Action> KeyBinding::getRealtimeActions() const
{
	// Return all realtime actions that are currently active.
	std::vector<Action> actions;

	for(auto pair : mKeyMap)
	{
		// If key is pressed and an action is a realtime action, store it
		if (sf::Keyboard::isKeyPressed(pair.first) && isRealtimeAction(pair.second))
			actions.push_back(pair.second);
	}

	return actions;
}