glad to know it works.

w = (500-200)/2;
x = random(w)-w;

The range of x will be (0 ~ 150)-150; That is (-150 ~ 0);

What we need is to make x range: -150 ~ 150;
So, I would use random(300)-150; That is (0 ~ 300)-150;