Q:

Issue With Collision c++

I am having a hard time with getting some basic collision to work. I have an image I am bouncing around in different shapes. Currently, I have made rectangle collision work. This was relatively easy since the lines where straight, so I was essentially just keeping the obj in a rect and if it went out of bounds of x1, x2, y1, or y2, I changed the velocity to its opposite. 
I am trying to accomplish the same thing inside of a triangle and am  having the hardest time with it. I have done some reading but for some reason the light switch in my brain is not turning on!
so I have a triangle... I have determined the slope by taking (y2 - y1)/(x2 - x1); however, I cannot make any progress in using the slope in the programming to cause the collision to register correctly.
I would provide some code but honestly nothing is even close to working lol.
Any advice on how to approach getting an obj to bounce around inside a triangle?
or, how to make an obj bounce off of a / style line?

A:

Depending how involved you want to get you might find Game Physics Engine Development helpful. The great thing about this book is that all the source code is available via GitHub and the specific source file for fine grain collision detection. The code is pretty clean and useable.

