I have some bad news. I tried to fix your code but there are a lot of stuff that are hard coded, management number that are reused and inconsistent game loop(You have two parts where you process inputs: One before rendering and the other after that). The thing is that the game engine need to be done again. IDK if you want to start over but I can give you the structure to improve your project.