@nspry,
There’s a lot going on here. I don’t know that I have a definitive answer for you, but I played with Box4 for a good 30 minutes or so and I could get it to work with small Mario in certain circumstances. Usually, I had to open one of the boxes below it first and reveal the mushroom. Then, I could go up top and jump over the mushroom (without eating it) and I would sometimes get Box4 to change.
I added some console.log statements inside the open4 function to see if it was getting called at all. It is getting called, but my current theory is that for some reason, right when you go to jump it isn’t active. I don’t know if I’m explaining that very well, but when I put console.log statements inside of open4( ), and I put watchers on the q4 and Mario.y values, I could see that although the q4 and Mario.y conditions were being met, the console.log statements weren’t running, so the program was “at that very instant” not running open4.
When I let it sit there and when I revealed the mushroom, eventually, I could get it to trigger.
As for a solution … I haven’t tried this, but is there a way you could perhaps rethink how and when you are calling the functions? Maybe there are so many functions running that it is having a hard time… I am not an expert at this, but maybe open4 could only be called when Mario.x is above a certain number, but that requires a different conditional to check for that, so I’m not 100% sure that would work.
Overall, unfortunately, I think the best solution would involve refactoring and simplifying the code (which would be a ton of work) to eliminate as much repetitious code as possible.
Instead of having so many different box sprites, for example, create a group called box and add sprites to that group. Then there are less collision functions to account 4 as it only has to check for collisions with a group and not each sprite in the group.
I realize this involves having to redo a ton of work and also to learn how groups work. There may be another way and there are definitely smarter people than me who visit this board and who may be able to help AND the scope of this project goes beyond any I have personally attempted, so take my advice based on that, but that’s just my opinion after having played with it for 30 minutes or so.
Sorry I can’t be of more help. If I think of anything else, I’ll be sure to chime in.
Good luck as you continue to debug!
Mike