Stack overflow in this Bird Game 3-Smash bros inspired game

every time the character interacts with a seed bag with health that isnt 100, the game calls a stack overflow even though i’ve made it so that it doesnt (as i know of so far)

here is the game link: https://arcade.makecode.com/S01604-06300-79790-72401

and if you think the code is atrocious, that’s all my bad because i only started three months ago

3 Likes

Using debug mode, the overflow comes from the blocks that sense whenever a players is equal to 100% m, check over there maybe.

2 Likes

Welcome! :waving_hand: Your code is very advanced for only starting three months ago, amazing job! I really enjoyed the silly art and competitive gameplay, I’d love to see more of this game :slightly_smiling_face:

@RedSprite is right, using debug mode you can see the stack overflow comes from this block:


The only way (to my knowledge) that a small block like that could cause a stack overflow error is if it was run over and over again.

So, I added a ‘Pause 2000 ms’ block after the error, so that code could only run once every 2000 ms, and used the console log block to constantly see what the player 1 health value was.

It seems that, even though at the end of the block the player 1 health is set to 50, it is immediately set to 100 by another block. I found this one:


I’m not sure what purpose it serves in the game; it may have been unfinished, as it currently sets both players to their maximum health when player 1 is fully healed, and the wrong health bars are used in parts.

For now, when I delete the block, the game works perfectly! :blush: Here’s the updated code.

I’m also a bit confused on why the woodpecker’s health is set to 50 (50% of its max value) when it is healed all the way. I can see in the code that at the beginning, the woodpecker’s max health value is 55 (so it would make sense to set the value to 50), but it is then a game update block sets the max to 100 for the rest of the game. It could be a remnant of an older version.

Let me know if that block I removed was important to the gameplay, or if my change caused any other glitches! :sparkling_heart:

2 Likes

Thank you so much for fixing the code! I was really stumped as to why this was occurring, and you swooped in and saved me! I didn’t even see that there was two of the same code haha. I’ve tested it with the multiple characters, and everything works well. I’ll post more updates on this game in the future!

1 Like