I am making an abacus simulator in p5 (sketch file) that does all the moves step by step. To animate the movement, I have variable x incrementally increase/decrease in a show function I created (lines 166 and 172), which is getting called in draw() over and over again. It knows what to do based on the state (bead on left or right side).
I am currently writing a function add(a, b) that adds two numbers. It works correctly, but it only animates the final answer instead of animating it step by step (lines containing //animate should be what animates). When I change the row variable (two-dimensional array) in a for loop, I would like to have it fully animate (I think by calling the show function within the loop) before iterating through the next row element. The lines with //animate in it are what I want to animate. I’ve tried doing a while loop to stall it, but it doesn’t work and show() needs to get called over and over again before proceeding.
I’ve even tried running a for loop (with distance / speed) which should be the number of times (11,100) show() would need to get called to fully animate to the other side. None of these things are working! Any ideas how I can make line execution not continue until it finishes animating (starting at line 93 in add())? Try it out first in the console with the add function. I am going to be doing some refactoring later.