Hello!
First I decided to rewrite the code and this time use classes. I created the class Car with methods for the controls, collisions, etc. In the main file, I just create 2 cars, car1 and car2 and can now easily adjust code order.
Then I tried fixing the collision bug. Since I rewrote the program, the bug kind of got fixed on its own. A similar bug still exists and I don’t know why, but I’ll either search for it tomorrow or ignore it as it is a rare case of when you collide diagonally and do “cross the wall”.
Another collision problem is, that the cars can sometimes go inside each other (a bit). It is due to me checking for the distance between a point and a line. It would be solved, if I check for collision between 2 lines. I’ll try that tomorrow.
Log in to leave a comment