当前位置: 首页>>代码示例>>C++>>正文


C++ CommandQueue::push方法代码示例

本文整理汇总了C++中CommandQueue::push方法的典型用法代码示例。如果您正苦于以下问题:C++ CommandQueue::push方法的具体用法?C++ CommandQueue::push怎么用?C++ CommandQueue::push使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CommandQueue的用法示例。


在下文中一共展示了CommandQueue::push方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: checkProjectileLaunch

void Aircraft::checkProjectileLaunch(sf::Time dt, CommandQueue& commands)
{
    // Enemies try to fire all the time
    if (!isAllied())
        fire();

    // Check for automatic gunfire, allow only in intervals
    if (mIsFiring && mFireCountdown <= sf::Time::Zero)
    {
        // Interval expired: We can fire a new bullet
        commands.push(mFireCommand);
        mFireCountdown += Table[mType].fireInterval / (mFireRateLevel + 1.f);
        mIsFiring = false;
    }
    else if (mFireCountdown > sf::Time::Zero)
    {
        // Interval not expired: Decrease it further
        mFireCountdown -= dt;
        mIsFiring = false;
    }

    // Check for missile launch
    if (mIsLaunchingMissile)
    {
        commands.push(mMissileCommand);
        mIsLaunchingMissile = false;
    }
}
开发者ID:gabrieljt,项目名称:learn-sfml,代码行数:28,代码来源:Aircraft.cpp

示例2: updateCurrent

void Tile::updateCurrent(sf::Time dt, CommandQueue& commands)
{
    // Entity has been destroyed: Possibly drop pickup, mark for removal
    if (isDestroyed())
    {
        checkPickupDrop(commands);
        mExplosion.update(dt);
        // Play explosion sound only once
        if (!mExplosionBegan)
        {
            // Play sound effect
            SoundEffect::ID soundEffect = (randomInt(2) == 0) ? SoundEffect::Explosion1 : SoundEffect::Explosion2;
            playLocalSound(commands, soundEffect);

            // Emit network game action for explosions
            if (isBlock())
            {
                sf::Vector2f position = getWorldPosition();

                Command command;
                command.category = Category::Network;
                command.action = derivedAction<NetworkNode>([position] (NetworkNode& node, sf::Time)
                                                            {
                                                                node.notifyGameAction(GameActions::EnemyExplode, position);
                                                            });

                commands.push(command);
                mExplosionBegan = true;
            }
        }
        return;
    }

    Entity::updateCurrent(dt, commands);
}
开发者ID:ffrujeri,项目名称:SFML-bomberman-clone,代码行数:35,代码来源:Tile.cpp

示例3: updateInput

void Player::updateInput(CommandQueue &command_queue)
{
    if (keyboard_works == true)
    for (auto &itr : key_to_action)
    {
        //If the key is pressed add to the set. If not then delete from the set.
        //If it's a new key then refresh the last_key_pressed and current_action
        if (sf::Keyboard::isKeyPressed(itr.first)) 
        {
            auto key = keys_pressed.find(itr.first);
            if (key == keys_pressed.end())
            {
                current_action = key_to_action[itr.first];
                last_key_pressed = itr.first;
            }
            keys_pressed.insert(itr.first);
        }
        else
        {
            auto key = keys_pressed.find(itr.first);
            if (key != keys_pressed.end()) keys_pressed.erase(itr.first);
        }
    }


    if(last_key_pressed != 0 && keyboard_works == true)
        command_queue.push(action_to_command[current_action]);
    //command_queue.push(action_to_command[key_to_action[last_key_pressed]]);
}
开发者ID:CarlosPerezPuertas,项目名称:Pacman,代码行数:29,代码来源:Player.cpp

示例4: handleEvent

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]);
    }
}
开发者ID:tristanklempka,项目名称:Purple-Xylophone,代码行数:16,代码来源:Player.cpp

示例5: dispatchCommand

bool Dispatcher::dispatchCommand( Command& command )
{
    EQVERB << "dispatch " << command << " on " << base::className( this )
           << std::endl;

    const uint32_t which = command->command;
#ifndef NDEBUG
    if( which >= _qTable.size( ))
    {
        EQABORT( "Command " << command
                 << " higher than number of registered command handlers ("
                 << _qTable.size() << ") for object of type "
                 << base::className( this ) << std::endl );
        return false;
    }
#endif

    CommandQueue* queue = _qTable[which];
    if( queue )
    {
        command.setDispatchFunction( _fTable[which] );
        queue->push( command );
        return true;
    }
    // else

    EQCHECK( _fTable[which]( command ));
    return true;
}
开发者ID:MichaelVlad,项目名称:Equalizer,代码行数:29,代码来源:dispatcher.cpp

示例6: dispatchCommand

bool Dispatcher::dispatchCommand( ICommand& command )
{
    LBASSERT( command.isValid( ));

    LBVERB << "dispatch " << command << " on " << lunchbox::className( this )
           << std::endl;

    const uint32_t which = command.getCommand();
#ifndef NDEBUG
    if( which >= _impl->qTable.size( ))
    {
        LBABORT( "ICommand " << command
                 << " higher than number of registered command handlers ("
                 << _impl->qTable.size() << ") for object of type "
                 << lunchbox::className( this ) << std::endl );
        return false;
    }
#endif

    CommandQueue* queue = _impl->qTable[ which ];
    if( queue )
    {
        command.setDispatchFunction( _impl->fTable[ which ] );
        queue->push( command );
        return true;
    }
    // else

    LBCHECK( _impl->fTable[ which ]( command ));
    return true;
}
开发者ID:OlafRocket,项目名称:Collage,代码行数:31,代码来源:dispatcher.cpp

示例7: checkPickupDrop

void Aircraft::checkPickupDrop(CommandQueue& commands)
{
    if (!isAllied() && randomInt(3) == 0 && !mSpawnedPickup)
        commands.push(mDropPickupCommand);

    mSpawnedPickup = true;
}
开发者ID:Nyssther,项目名称:SFML-Game-Development-Book,代码行数:7,代码来源:Aircraft.cpp

示例8: playLocalSound

void Entity::playLocalSound(CommandQueue &commands, Sounds::ID sound)
{
    Command command;
    command.category = Category::SoundEffect;
    command.action = derivedAction<SoundNode>(std::bind(&SoundNode::playSound, std::placeholders::_1, sound, getWorldPosition()));

    commands.push(command);
}
开发者ID:Lo-X,项目名称:potato-framework,代码行数:8,代码来源:entity.cpp

示例9: handleRealtimeInput

void Player::handleRealtimeInput(CommandQueue& commands)
{
    for (auto pair : mKeyBinding)
    {
        if (sf::Keyboard::isKeyPressed(pair.first) && isRealtimeAction(pair.second))
            commands.push(mActionBinding[pair.second]);
    }
}
开发者ID:gabrieljt,项目名称:learn-sfml,代码行数:8,代码来源:Player.cpp

示例10: handleEvent

void Player::handleEvent(const sf::Event& event, CommandQueue& commands) {
    if (event.type == sf::Event::KeyPressed) {
        // Commands happen when the player presses a key that corresponds with a command
        auto found = mKeyBinding.find(event.key.code);
        if (found != mKeyBinding.end() && !isRealtimeAction(found->second))
            commands.push(mActionBinding[found->second]);
    }
}
开发者ID:x00112310,项目名称:Space-Shooter-Game,代码行数:8,代码来源:Player.cpp

示例11: handleRealtimeInput

void Player::handleRealtimeInput(CommandQueue& commands) {
    // Checks every key for a press
    for (auto pair : mKeyBinding) {
        // if something is pressed make sure to trigger command
        if (sf::Keyboard::isKeyPressed(pair.first) && isRealtimeAction(pair.second))
            commands.push(mActionBinding[pair.second]);
    }
}
开发者ID:x00112310,项目名称:Space-Shooter-Game,代码行数:8,代码来源:Player.cpp

示例12: handleRealTimeInput

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]);
    }
}
开发者ID:tristanklempka,项目名称:Purple-Xylophone,代码行数:18,代码来源:Player.cpp

示例13: checkPickupDrop

void Tile::checkPickupDrop(CommandQueue& commands)
{
    // Drop pickup, if enemy airplane, with probability 1/4, if pickup not yet dropped
    // and if not in network mode (where pickups are dropped via packets)
    if (isBlock() && randomInt(5) == 0 && !mSpawnedPickup && mPickupsEnabled){
        commands.push(mDropPickupCommand);
    }
    mSpawnedPickup = true;
}
开发者ID:ffrujeri,项目名称:SFML-bomberman-clone,代码行数:9,代码来源:Tile.cpp

示例14: handleRealTimeInput

void Player::handleRealTimeInput(CommandQueue& commands)
{
  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]);
  }
  
}
开发者ID:fvalenza,项目名称:sfml-test,代码行数:10,代码来源:player.cpp

示例15: checkProjectileLaunch

void Aircraft::checkProjectileLaunch(sf::Time delta, CommandQueue& commands)
{
  if (!isAllied()) fire();

  if (bFiring && mFireCountdown <= sf::Time::Zero) {
    commands.push(mFireCommand);
    mFireCountdown += sf::seconds(1.f / (mFireRateLevel + 1));
    bFiring = false;

    playLocalSound(commands, isAllied() ? SoundEffects::AlliedGunfire : SoundEffects::EnemyGunfire);
  } else if (mFireCountdown > sf::Time::Zero)
    mFireCountdown -= delta;

  if (bLaunchingMissile) {
    commands.push(mMissileCommand);
    bLaunchingMissile = false;
    playLocalSound(commands, SoundEffects::LaunchMissile);
  }
}
开发者ID:shan-wyse,项目名称:SFML-Game-Dev,代码行数:19,代码来源:Aircraft.cpp


注:本文中的CommandQueue::push方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。