Problem with width/2 and height/2

As mentioned before, The proper place to access width and height are in setup (also draw, mousePressed, etc). Setup is a great function to init your variables that depend on the size of your sketch. If you init them in the global scope, it is not guarantee size() is executed on time and your global variables would be evaluated first.

Kf