Can I improve the efficiency here?

I’ve made this activity to reproduce an old Flash game: REFACTOR Flip and Slide Game (Rigid transformations practice) • Activity Builder by Desmos

It works properly, but the animation feels too choppy to me. I think the issue is that I have 70 individual actions that continuously check to see if each bubble is located within the triangle by ray casting, but I’m not sure. These are all in the “bubbles to catch” folder in the graph on the left.

I’ve also noticed that, as the activity runs, it seems to slow down over time, and I’m not sure what would be causing that or if I am just imagining it. It definitely runs slower on my machine when I am editing it and testing it in preview versus after it is published and I’m testing it in student preview mode from the activity page.

I’m wondering if anyone can see a way to simplify what I am doing here and to improve performance.

2 Likes

Instead of having 70 individual actions that continuously check to see if each bubble is located within the triangle, consider simplifying your code by creating a single function that performs the ray casting calculation for all the bubbles. This can reduce the amount of code you need to write and make it easier to debug and maintain.