Hi,
Welcome to the forum!
Remember to put your code between backticks like this ``` ``` or use the </>
button when editing a message. (you can also edit your previous message)
You might want to look at this previous thread for rectangle collision :