Updating variables every frame

I was going to say. Coming from c#, it didn’t make any sense to me that we declared the edge positions only once outside the while loop. It had me wondering if c++ variables work more like functions. Good to know that it’s not so fundamentally different after all.

I think it’s a bit cleaner to just keep the initial declaration (before the while loop) as:

collision_with_axe{false};

Since the game will always start with the circle and axe in the same position which is not colliding.

Also it seemed to make a bit more sense from a program flow perspective to have the edge updating and collision detection take place after drawing the shapes and implementing the movement, but it doesn’t make a difference for the functionality and may be a matter of personal taste.

I agree with you there, at the end of the day you’re not likely going to see the difference.

Privacy & Terms