How do I add collision between player projectile and enemies?

I’m currently working on changing my wall collision to this type of collision.
I’ve managed to get the player to recognise that its collided with the wall, but how do I make it stop when it touches the wall? Right now the player still goes into the wall, but knows its collided with a wall.

I’m controlling the player using arrow keys