Collision detection can be quite a complex or at least confusing topic, fortunately you guys are not alone, but there are thousands of other people who had the same problem in the past, that's why you can find a lot with Google.
One result after 1min searching seems promising, although the code is only available if registered, I think, but it's explained quite well.
Some keywords to search for:
- line rectangle collision detection (if your player is a rectangle)
- line AABB intersection (if your player is a AABB)
- line polygon collision detection (if your player is a polygon)
But keep in mind, you'll need some mathematical understanding in most cases.