Student Project bug error, needing help

This is a student’s project. I am not sure how to help him. I haven’t ever seen this error either. Any help is greatly appreciated.

Link to the project or level: https://studio.code.org/projects/gamelab/ICZRDiZ05f6oRXA8DGJ4AZWpUKm6g6q3caCL1rInTxo

What I expect to happen: I am not sure what the error means. The student has stopped working on it because he is stuck. I am not sure if it is a background error.

What actually happens: Nothing shows up and the background is not working at all.
What I’ve tried: He said that he has tried lots of different things. I am not sure how to help at all.

Hi @cwaliser,

I can’t see the project due to sharing error. Can you make sure your student’s settings allow for sharing?

Some things that I do see, and this may not have anything to do with the error, but I notice the function is named “background”. It’s a good rule of thumb to name functions unique names that the language doesn’t already own in some way such as myBackground. And possibly related to that, I see on line 13 he uses the blue block for background(). This does not call the function that he created but rather this is a block of code that creates a background color. There should actually a parameter inside the blue block with a color value like background(“blue”). To call the function, you need to go to the green function blocks and drag out a function call block and enter the exact name of the function.

Try those adjustments and see if that fixes the error. If not, can you adjust the sharing settings so we can see the project?

Hope those tips help but let us know!
Michelle

2 Likes

Maximum call stack can happen with recursive functions. The program overwrote the native background function on line 19. On line 20, the new background is called again. This process will loop again and again until the call stack reaches an integer limit.

This is where tools like step in would come in handy. It shows what is being executed step by step.

The solution to this problem is simple, don’t overwrite native p5.js functions and instead name the function background_function or something along those lines.

2 Likes

Thanks @infinitestasis. Nice description of recursion.
~Michelle