Hardware Crash calling 'fin' - but same code runs fine in Pulp simulator - any ideas?

So I'm completely new to game development (unless you count typing out games in basic for the ZX Spectrum back in the day). Thanks to excellent intro to pulp videos from SquidGodDev I got some linked levels running in Pulp but when run on actual hardware it was crashing when calling fin. I've found a workaround but just wondered if anyone had any ideas as to why?

Situation was that when the player position was the same as an enemy sprite, the sprite would tell event.game to call 'damagePlayer'. Then within damagePlayer I had sound "ouch" and health-=1 followed by a check for if health<=0 then fin
This ran fine in the simulator but crashed the playdate with an " attempt to index a nil value" . There were two sprite instances in separate rooms calling damagePlayer in this way and it was only the first one that caused the crash on the hardware. (I had the same issue when damagePlayer was called by event.player too)

My workaround is that damagePlayer now checks if health<=0 and then presents ' ask ' with options to continue or not. The 'continue' option under ask calls 'fin' and this works fine in all instances on simulator and hardware.

Just wondered if anyone had any idea why this was happening or what I had possibly done wrong in my first use case?

I'm not sure why, but there do seem to be some issues when it comes to fin on actual hardware. Someone else made a game which would end correctly using Pulp in a browser (fin being called from an item I think), but it would cause the Playdate hardware to crash. Not the same issue as you have, but there seem to be some bugs there.

1 Like

I'm going to test out your timing theory. There's another game I've found with the same issue, so hopefully I can compare and work out where/why its failing on the hardware. I think ultimately it comes down to the fact that the simulators are not emulators and so there will always be differences when run on real hardware. So glad my playdate finally arrived so I can test!