Variable suddenly adds instead of minus a value after some unrelated variable changed

repl link:

somehow, once any one of the two prints on line 152 and 162 (the print itself is unrelated, I just added them for bookmarking where does the problem begins) is executed by fullfiling the if statement conditions, the ball representing the first index of idx1 for loop just ‘falls’ up instead of down, by somehow adding the 9.81 in line 291 instead of subtracting, idk how

expected behavior: any other balls, either stay in the air or fall and collide
unexpected behavior: that one ball on the right after 0:15 when it suddenly changes gravitational direction

program is project/, any custom module (engine) is most likely to be unrelated to this

Any chance to exist a scenario where self.var_delta_time * 9.81 ends up being negative or behaves unexpectedly?

no, the only 2 things that changes the variable is declaration (it is 0.01) and timer set (commented so it doesn’t actually run, but according to the real world time can’t be negative anyways), none of them is or can be negative.

Also the weirdest part is that only 1 sprite in that for loop will have the acceleration subtracted instead, but there is no condition statements so it should either be all sprite subtracts acceleration or add acceleration, which isn’t the case, python isn’t pythoning right now.

Also I kinda wanna test if it’s my repl’s problem or something so can any of you try to fork my project and run it, wait until frame is somewhere above 1500 and stop the repl then run project/out/, I think it’s more likely to not be code problem or something now because for loop isn’t doing it’s job or sth

update: I decided to not care the issue and continue the project according to the roadmap, and somehow it’s fixed somewhen I rendered the video again, I dont know when, how and why it got fixed tho

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.