We programmers use our fingertips to bring ideas (provided by our delightful designers) and art (provided by our amazing artists) to life. The raw pieces are separate and motionless at first, but with a little bit of code, we bring them all together and make them move about.
Sometimes, things don’t move the way we thought they would. When I first programmed the rope slicing in the Dreamscapes minigame, I didn’t anticipate just how fast fingers can move across a screen. A fast finger could end up missing the rope if the finger’s frame-by-frame position skipped over the rope.
Time for a new approach! Rather than a basic collision check, how about tracking when the slice intersects the rope? That method sounds much more promising, even if more involved. As a finger moves across the screen, it moves from point A to point B, creating a new line segment with each new frame. A rope is also just a collection of line segments. There is enough information to calculate the point at which these line segments intersect, if they intersect. Using this method, even if a finger starts on one side of the rope in one frame and then ends up on the other side of the rope in the next frame, it will still get sliced. With the plan in mind, implementation can get under way.
After implementing the new method, the ropes get sliced as intended, even with really fast fingers!