You simply need a reworked Newton's law of universal gravitation.
So F=G(M1*M2)/R2 translates as code into.
// Create force scalar based off of distance.
distanceSquared = (gravityCenter.y - object.y)^2 + (gravityCenter.x - object.x)^2
force = gravitationalConstant*distanceSquared
// Get direction from object to gravity epicenter.
direction = arctangent2(gravityCenter.y - object.y, gravityCenter.x - object.x)
// Transform vector into into coordinate based impulse.
object.xVelocity += force*cosine(direction)
object.yVelocity += force*sine(direction)
Then adjust gravitationalConstant to suit.
NOTE: Unless you want to send ships into space, implementing gravity based on distance is completely a waste of cycles as a constant "downwards" force is more processor friendly.