I will use the actions shown in the lego-scene for some kind of pseudo-code
So what actions does the animated lego-scene show:
- fish "swimming along the aquarium glass wall in circles"
- foot of the fishingman tapping from time to time
- pulling up the mans body and the fishing-rod from time to time
- head of the cat looking up in parallel to the hook moving up
- tail of the cat moving from time to time
First important thing:
these actions are driven by a continiously rotated crank-wheel
the fish is moving all the time but the other actions happen only from time to time
The chain moving all the time but pulling up the fishing-rod happens only if the lever moves across a certain point.
The coding equivalent to this behaviour is non-blocking timing.
The basic principle of non-blocking timing is calculating how much time has passed by since a time-reference-point. This means a difference between time-reference-point and actual time is calculated. This difference is "how much time has passed by. And then this difference is checked "has a certain amount of time passed by (since time-reference-point)
If this certain amount of time has really passed by then take action!
Non-blocking timing is a thing on its own which I have described in the tutorial mentioned below.
I'm aware that linking to this other tutorial is sub-optimal. It is what I have so far.