I did check out your ejs code.
There are several strange code
1. Why the drawingPanel was assigned to be autoscale?
2. Why maxX= -carSize/2 ???
3. Why Lmax was not defined?

You should have assigned initlal value for defined variables.
I do not know how to change your code because I do not know the specification for your simulation.

The code in the event are strange,too!

If I have something bounced between xmin and xmax (xmax>xmin)

I will have code like this for zero condition:
if (v>0)return x-xmax; // bounced at x=xmax
else if(v<0)return x-xmin; // bounced at x=xmin
return 1;
// the event occurs when return value is less than zero.

And the action will be

/htdocs/ntnujava/ejsuser/2/users/ntnu/fkh/bump_pkg/bump.propertiesFull screen applet or Problem viewing java?Add http://www.phy.ntnu.edu.tw/ to exception site list
Press the Alt key and the left mouse button to drag the applet off the browser and onto the desktop. This work is licensed under a Creative Commons Attribution 2.5 Taiwan License
Download EJS jar file(1339.6kB):double click downloaded file to run it. (2 times by 1 users) , Download EJS source (2 times by 1 users) View EJS source