How to do Acceleration?

I’m new to python, my current project is a Sonic clone. I want the character to increase speed over time when a button is pressed then resets when let go. I experimented and I found no way to do this.

    
    Sprint = bge.logic.KX_INPUT_ACTIVE == keyboard.events[bge.events.LEFTSHIFTKEY]
    
    speed = .1
    jump_height = .1
    
    if Sprint:
        speed = .1+2 <-- This only makes it 2.1 but I want it to keep adding 2 as time passes. 


main()

what physics type is your character? Rigid body? dynamic?

My character’s physics is dynamic.

You have to take into account the behaviour of the sensor you use to trigger the python script above. The standard behaviour of a sensor is to fire only once (when the button is pressed for example). What you might need for the sensor is to fire continually.

See here, look for “true level triggering”
http://www.blender.org/manual/game_engine/logic/sensors/common_options.html