I have a few remarks:
You may have a problem with this line of code:
float slope = (y1 - entity->y1) / (x1 - entity->x1);If
entityis already at the longitudex1, this will cause a division by 0. Such a division is undefined behaviour. Anything can happen. A plane may crash on your house. You should check first whetherx1 == entity->x1and handle this case properly. I see that the lastelseclose of your program handles this case (//When the player shoots up or down), but the division by 0 appears before you handle it.I don't know whether
entity.xandentity.yareintorfloattypes. If they areinttypes, I guess that you can get rid of thefloatvariables: the only thing that may need more prceisionprecision than an integer isslope, and ifentity.xandentity.yare integer types, thenslopewill contain an integer castedcast to afloat(since it was intializedinitialized with an integer division).
It lacks a bit of context to provide a complete review. You should post the code of at least Map and Entity so that we don't have to assume things.