This MakeCode project was focused on abstraction… and it humbled me.
I went into it thinking it would be a quick build. My plan felt simple: instead of donuts subtracting points, I wanted them to add points. I also wanted one type of donut to be worth more than the other. Conceptually, it made sense. In practice, everything broke.
The main issue? I could not get multiple donuts to continue spawning across the screen. I kept adjusting the function and overlap logic, but something was off.

At one point, I did not even get to the “bells and whistles” because the basic mechanics refused to cooperate.
Here is my first iteration of the game (click to play):

After some serious frustration, my professor helped me identify the bug. The issue was not in the scoring logic at all. It was in my tile setup.

Both tile types existed on both sides of the wall. That meant donuts would sometimes spawn on the right side and move right, or spawn on the left side and move left. Technically, the code was working. Visually, nothing appeared to move across the screen.
It was not an abstraction problem but a spatial logic problem. Once I separated the tile types so they were consistently placed on opposite sides, the spawning worked much more consistently.
Here is the corrected version (click to play):

That said, the game is still not perfect. The smaller donuts do not always continue spawning the way I originally envisioned. Sometimes only one or two appear before stopping. There is still something in my logic that needs refining. And honestly, that feels important to say.
This experience taught me something critical about abstraction in programming. When we create generalized functions, we assume the environment supports them. But abstraction only works when the underlying system is consistent and fully aligned with the logic we design.
I was so focused on making the donuts “smarter” that I missed a simple environmental constraint. And now, even in the improved version, I can see there are still edge cases I have not accounted for. Debugging forced me to slow down, isolate variables, and test assumptions. It was frustrating in the moment, but incredibly clarifying afterward.
Abstraction makes systems manageable, but it demands precision. And sometimes, the bug is not where you think it is.
Leave a comment