Hey all! Hope you are doing well.
I am having a difficult time understanding the math/logic behind
if(AxeY > 450)
{
AxeDirection = -AxeDirection;
}
and why it moves DrawRectangle in the opposite direction.
My initial expectation is that as soon as the box is at 449, it would exit the if statement and just keep adding AxeDirection(originally initialized as 10). Therefore, going back and forth between 440 and 450 until the while loop is closed via WindowShouldClose().
Is it because AxeDirection stays at -10 because the initialization is outside of the while loop and therefore, doesn’t get reinitialized? Would the box get stuck at 440 if AxeDirection was initialized to 10 inside of the while loop? I am confused!