This study presents a sub-optimal control algorithm that implements real-time collision avoidance maneuvers for spacecraft in proximity operations. The penalty function for avoiding collision with an obstacle is first incorporated into the performance index of a typical optimal tracking problem in a discrete-time domain. Then, the infinite-horizon control law is derived by employing generating functions based on the discrete-time Hamilton-Jacobi theory without initial guess and iterative procedure. The derived control law, which is an explicit function of the states of desired solution and obstacles, allows us to avoid collision in real-time. The proposed approach has advantages over the previous optimal collision avoidance approaches requiring repetitive procedure and initial guess, and/or trajectories of obstacles to be known a priori. Numerical simulations demonstrate that the proposed algorithm is suitable for implementing optimal collision-free transfers in real-time.