Here’s the actual math to do it. Equation 5 to calculate the impulse and 1a,1b to set the new speeds.
en.m.wikipedia.org/wiki/Collision_response
You don’t have to do the angular stuff so it can be simpler.
Sprite collides with other
Set a to angle(sprite.x,sprite.y,other.x,other.y)
set j to -(1+e)*((other.vx-sprite.vx)*cos(a)+(other.vy-sprite.vy)*sin(a))/(1/Sprite.mass+1/other.mass)
Sprite: set vx to self.vx-j/self.mass*cos(a)
Sprite: set vy to self.-j/self.mass*sin(a)
Other: set vx to self.vx+j/self.mass*cos(a)
Other: set vy to self.vy+j/self.mass*sin(a)
That’s with three variables
a = the angle from sprite to other
e = bounce amount. 0 to 1 range
j = the impulse
Also I used vx and vy for the velocities. You can get that from angle and speed with:
Vx=speed*cos(angle)
Vy=speed*sin(angle)
And vice versa
Speed = distance(0,0,vx,vy)
Angle = angle(0,0,vx,vy)
Anyways hope that helps.