Adding additional Entities to game causes player to move slower
<p><strong>Warning: Big post, small problem</strong></p>

<p>I'm trying to use SFML 2.3.2 to make a game, things have been going pretty well. I've got moving platforms, a movable, jumping, colliding player character (albeit a box). And I'm also making things move distance according to time passed instead of according to a locked framerate, but it seems I messed up somewhere.</p>

<p><strong>The Problem:</strong></p>

<p>The more Entities I add (boxes for my player character to collide with and moving platforms) the slower the player moves and the lower he jumps, despite using a (deltaTime * movement speed) calculation (The moving platforms seem to be consistent in their movements though, no matter the quantity of Entities)</p>

<p>This is the biggest project I've made up to this point so I'll try my best to give all the relevant information.</p>

<p>So first I'll show the structure of all of the files in my project, that way if there's code that's needed that I left out you can just ask me "Hey, what's in there?". Besides that I'll copy the code that I think is relevant to this problem. Which is code of the Engine(a veeeery basic one), Player, and VelocityModule</p>

<p><strong>Project Files:</strong></p>

<p>.h = header file only</p>

<p>.cpp = source file only</p>

<p>.h/.cpp = both header and source files</p>

<p><strong>Dutchtilities:</strong></p>

<ul>
<li>DutchFunctions.h/.cpp</li>
<li>ExternalInclusion.h</li>
<li>gameHeaders.h</li>
<li>sheepPointer.h</li>
</ul>

<p><strong>Entities:</strong></p>

<ul>
<li>Entity.h/.cpp</li>
<li>MovingPlatform.h/.cpp</li>
<li>Player.h/.cpp</li>
<li>Quadrangle.h/.cpp</li>
<li>EntityPack.h (Collection of all other Entity headers)</li>
</ul>

<p><strong>Modules:</strong></p>

<ul>
<li>Module.h/.cpp</li>
<li>TransformModule.h/.cpp</li>
<li>HitboxModule.h/.cpp</li>
<li>DrawModule.h/.cpp</li>
<li>VelocityModule.h/.cpp</li>
<li>ModulePack.h (collection of all other module headers)</li>
</ul>

<p><strong>System:</strong></p>

<ul>
<li>Engine.h/.cpp</li>
<li>Level.h/.cpp</li>
<li>Reader.h/.cpp</li>
</ul>

<p>I believe the problems are centred around the VelocityModule and the way it updates</p>

<p><strong>Relevant Code:</strong></p>

<p>Engine.h</p>

<pre><code>#ifndef ENGINE_H
#define ENGINE_H

// Forward Declaration
class Level;
#include "Reader.h"

class Engine
{
public:

    // Functions - System
    bool            update();
    void            initWindow();

    // Functions - Time
    sf::Time        getLastFrameTime();
    void            resetLastFrameTime();

    // Functions - Camera
    void            updateCamera();
    void            setCameraTransform( TransformModule* transform );
    void            setCameraOffset( sf::Vector2f &amp;offset );
    void            setCameraOffset( float x, float y );
    sf::Vector2f    getCameraOffset();

    // Functions - Window
    void            setWindowName( const std::string &amp;name );
    void            setWindowDimensions( sf::Vector2u &amp;widthHeight );
    void            setWindowDimensions( unsigned width, unsigned height );
    sf::Vector2u    getWindowDimensions();

    // Functions - Levels
    void            loadLevel( Level* level );

    // Variables - Camera
    sf::View                camera;

    // Variables - Time
    sf::Clock               clock;
    sf::Time                deltaTime;

    // Variables - Window
    sf::RenderWindow        window;

    // Variables - Reader
    Reader                  fileReader;

    // Structors
    Engine();


protected:

    // Variables - Level
    Level*                      m_level;

    // Variables - Camera
    sheepPtr&lt;TransformModule&gt;   m_cameraTarget;
    sf::Vector2f                m_cameraOffset;

    // Variables - Time
    float                       m_frameTime;

    // Variables - Window
    sf::Event                   m_eventHandler;
    std::string                 m_windowName;
    sf::Vector2u                m_windowDimensions;

    // Variables - Game Loop
    bool                        m_paused;
};

#endif
</code></pre>

<p>The engine contains 3 functions I believe to be important:</p>

<ul>
<li>update() this is the main game loop</li>
<li>getLastFrameTime()</li>
<li>resetLastFrameTime()</li>
</ul>

<p>Engine::update()</p>

<pre><code>bool    Engine::update()
{
    this-&gt;resetLastFrameTime();

    bool isRunning = true;

    // if the window is open...
    if( this-&gt;window.isOpen() )
    {
        // Shortcuts
        Level &amp;level = *(this-&gt;m_level);


        // LOOK AT WINDOW EVENTS ////////////////////////////////////////////////////////////////////////////////////////////////

        // Keyboard Events
        while( window.pollEvent( this-&gt;m_eventHandler ) )
        {
            // Stop program when X is pressed
            switch( this-&gt;m_eventHandler.type )
            {
            case sf::Event::Closed:
                this-&gt;window.close();
                isRunning = false;
                break;
            }
            // Pause/Resume game when escape is pressed
            if( this-&gt;m_eventHandler.type == sf::Event::KeyReleased &amp;&amp;
                this-&gt;m_eventHandler.key.code == sf::Keyboard::Escape)
            {
                this-&gt;m_paused = !m_paused;
                std::string line = (m_paused) ? "Game has paused\n" : "Game has unpaused\n";
                std::cout &lt;&lt; line;
            }
        }

        // The main game loop
        if( this-&gt;window.hasFocus() &amp;&amp;
            m_paused == false )
        {
            // UPDATE ENTITY HITBOXES ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            level.hitboxUpdateEntities();
            // APPLY VELOCITIES TO TRANSFORMS ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            level.updateVelocities();
            // DETECT COLLISIONS //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            level.resetCollisionLists();
            level.createCollisionLists();
            // APPLY EFFECTS ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            level.updateEntities();
            // ADJUST FOR COLLISION ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            level.adjustHitboxes();
            // DRAW STUFF /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            level.updateDraws();


            this-&gt;updateCamera();
            this-&gt;window.display();
            this-&gt;window.clear();
        }
    }
    // Otherwise the window has closed
    else
        isRunning = false;

    return isRunning;
}
</code></pre>

<p>Engine::getLastFrameTime()</p>

<pre><code>sf::Time        Engine::getLastFrameTime()
{
    return this-&gt;deltaTime;
}
</code></pre>

<p>Engine::resetLastFrameTime()</p>

<pre><code>void            Engine::resetLastFrameTime()
{
    this-&gt;deltaTime = clock.getElapsedTime();
    this-&gt;clock.restart();
}
</code></pre>

<p>Player.h</p>

<pre><code>#ifndef PLAYER_H
#define PLAYER_H

class Player : public Entity
{
public:

    void virtual update() final;
    void virtual hitboxUpdate() final;

    short health;
    float movementSpeed;
    float jumpingPower;

    Player();
    ~Player();


private:

    // Modules
    sheepPtr&lt;TransformModule&gt;   transform;
    sheepPtr&lt;DrawModule&gt;        draw;
    sheepPtr&lt;HitboxModule&gt;      collisionHitbox;
    sheepPtr&lt;HitboxModule&gt;      jumpHitbox;
    sheepPtr&lt;VelocityModule&gt;    velocity;

    bool m_grounded;
};

#endif // PLAYER_H
</code></pre>

<p>Functions I believe to be important:</p>

<ul>
<li>hitboxUpdate()</li>
</ul>

<p>Player::hitboxUpdate()</p>

<pre><code>void Player::hitboxUpdate()
{

    // Calculate the distance the player will move this update
    float distance = (this-&gt;movementSpeed * this-&gt;m_pEngine-&gt;getLastFrameTime().asSeconds() );


    // Jumping (Up)
    if( sf::Keyboard::isKeyPressed(sf::Keyboard::Space) &amp;&amp;
        this-&gt;m_grounded == true)
    {
        this-&gt;velocity-&gt;addVelocity( sf::Vector2f( 0, -(this-&gt;jumpingPower) ));
    }
    // Left
    if( sf::Keyboard::isKeyPressed(sf::Keyboard::A) )
        this-&gt;velocity-&gt;addVelocity( sf::Vector2f( -distance, 0 ));
    // Right
    else if( sf::Keyboard::isKeyPressed(sf::Keyboard::D) )
        this-&gt;velocity-&gt;addVelocity( sf::Vector2f( distance, 0 ));
}
</code></pre>

<p>VelocityModule.h</p>

<pre><code>#ifndef VELOCITYMODULE_H
#define VELOCITYMODULE_H

class VelocityModule : public Module
{
public:
    // Functions - System
    void            update();

    // Functions - Velocity
    void            addVelocity( sf::Vector2f &amp;velocity);
    sf::Vector2f    getVelocity();
    void            setVelocity( sf::Vector2f velocity );
    void            applyVelocity();
    void            setMaxVelocity( float maxVelocity );
    float           getMaxVelocity();
    void            setMinVelocity( float minVelovity );
    float           getMinVelocity();


    // Functions - Drag
    void            setDrag( float dragForce );
    float           getDrag();
    void            setApplyDrag( bool trueOrFalse );
    bool            getApplyDrag();

    // Functions - Gravity
    void            setGravity( float gravity );
    float           getGravity();
    void            setApplyGravity( bool trueOrFalse );
    bool            getApplyGravity();

    // Functions - Transform
    void                setTargetTransform( TransformModule* transform );
    TransformModule*    getTargetTransform();

    // Structors
    VelocityModule();
    ~VelocityModule();

private:
    // Variables - Velocity
    sf::Vector2f            m_velocity;
    float                   m_minVelocity;
    float                   m_maxVelocity;


    // Variables - Drag
    float                   m_dragForce;
    bool                    m_applyingDrag;
    static const float      MAX_DRAG;
    static const float      MIN_DRAG;

    // Variables - Gravity
    float                   m_gravityForce;
    bool                    m_applyingGravity;

    // Variables - Transform
    sheepPtr&lt;TransformModule&gt; m_targetTransform;

};

#endif // VELOCITYMODULE_H
</code></pre>

<p>VelocityModule functions I believe to be relevant:</p>

<ul>
<li>update()</li>
<li>addVelocity()</li>
<li><p>applyVelocity()</p>

<p>void            VelocityModule::update()
{ </p>

<pre><code>// Shortcut frametime
float seconds = this-&gt;m_pParentEntity-&gt;getLinkedEngine()-&gt;getLastFrameTime().asSeconds();


// Apply Gravity, if it's enabled
this-&gt;m_velocity.y += ( this-&gt;m_applyingGravity ) ? (this-&gt;m_gravityForce * seconds) : 0 ;
// Apply drag, if it's enabled
this-&gt;m_velocity *= ( this-&gt;m_applyingDrag ) ? pow( 1 - (m_dragForce/100), seconds ) : 1 ;

// Shortcutting via calculations
sf::Vector2f absoluteVelocity = sf::Vector2f(abs(this-&gt;m_velocity.x), abs(this-&gt;m_velocity.y));
float maxFrameVel = this-&gt;m_maxVelocity * seconds;
float minFrameVel = this-&gt;m_minVelocity * seconds;

// Change velocities according to maximum and minimum barriers
this-&gt;m_velocity.x = ( absoluteVelocity.x &lt; minFrameVel ) ? 0 :
                     ( absoluteVelocity.x &gt; maxFrameVel &amp;&amp; m_velocity.x &lt; 0 ) ? -maxFrameVel :
                     ( absoluteVelocity.x &gt; maxFrameVel &amp;&amp; m_velocity.x &gt; 0 ) ? maxFrameVel :
                      m_velocity.x;

this-&gt;m_velocity.y = ( absoluteVelocity.y &lt; minFrameVel ) ? 0 :
                     ( absoluteVelocity.y &gt; maxFrameVel &amp;&amp; m_velocity.y &lt; 0 ) ? -maxFrameVel :
                     ( absoluteVelocity.y &gt; maxFrameVel &amp;&amp; m_velocity.y &gt; 0 ) ? maxFrameVel :
                      m_velocity.y;


this-&gt;applyVelocity();
</code></pre>

<p>}</p></li>
</ul>

<p>VelocityModule::addVelocity()</p>

<pre><code>void            VelocityModule::addVelocity( sf::Vector2f &amp;velocity)
{
    this-&gt;m_velocity += velocity;
}
</code></pre>

<p>VelocityModule::applyVelocity()</p>

<pre><code>void            VelocityModule::applyVelocity()
{
    if( m_targetTransform.ptr != nullptr )
    {
        // Shortcutting
        this-&gt;m_targetTransform-&gt;move( this-&gt;m_velocity );
    }
}
</code></pre>