[s]You did not set up the correct initial condition.

Initially, your v=0, and x+carSize/2=-0.9  , xbumperbottom=0

so if(x+carSize/2>xbumperbottom) return 0;
is always satisfied. so acceleration is always zero and velocity is never changed (stay zero).

The computer does what you want it to do.

The above code will not stop car move to the right of xbumperbottom.
It only stop the car from accelerating, it will keep move with constant velocity if the car have some finite velocity.

Think about the physics when you model it! EJS is a physics modeling tool! ;)[/s]