I don't think the OP was asking for a physics lesson.
There are thousands of factors that will go into play that cannot be controlled. He's asking for quantifiable controllable changes that he can make to his gun to improve accuracy and range.For example; He cannot change the gravitational constant of the universe but it will effect the range of his shots so there's no point in discussing it here.
As was said before, there are many simple things you can do.
The simplest is use a heavier bb. As it will not be effected as greatly as a lighter one. Also buy the best quality you can find. I have used BB bastards and I found them excellent.
Moving from there, increasing the power of the spring your using is usually the next step. And so on and so forth.