Hi everyone, first post here.
I was wandering about the section of the code in which we set the conditions for the collision detection. My thought process is that if 1 of the 4 conditions is fulfilled, the collision happens and to be honest, is what seems to be to happen on practice. However, the code states the following:
collision_with_axe =
(b_axe_y >= u_circle_y) &&
(u_axe_y <= b_circle_y) &&
(r_axe_x >= l_circle_x) &&
(l_axe_x <= r_circle_x);
I have little experience with coding, so forgive me if I am wrong, but I have a basic understanding of what’s happening because of the aforementioned. So, my logic was to use the OR operator (||) in this situation, which with my testing seems to be the correct choice (in terms of the logic): as soon as I touch just 1 corner of the axe, the game over is triggered (I lowered the framerate to test it out). The actual code gets this job done of course; however, the logic seems odd.
Given that we are using the AND (&&) operator for all 4 conditions, this should mean ALL 4 conditions should happen AT THE SAME TIME in order for the collision to work, but in the end, it works as soon as ONE of the conditions happens. Is this a C++ thing or am I missing the mark completely here?