After updating Pico8 from 0.2.4c to 0.2.5g, I seem to com accross a strange kind of bug that spawns enemies on their own after waiting long enough:
It seem to consistently spawn a slime at the center, a shadow pig from below, and later a shadow pig at the top, these enemies are completely functional, so they seem to have spawned in, they also spawn consistently at the same level too.
You can see it for yourself here, it's at level 3:
I've been trying to debug it, going after each function that spawns in enemies, but it only seem to happen at the makeenemyfromsprite()
function, which spawns an enemy based on the sprite on the map.
Specifically the makeenemyfromsprite(32, 0, x, y)
and makeenemyfromsprite(34, 9, x, y)
This is strange, because the function itself should only run when loading the level, and the locations where it spawns the enemy doesn't relate to the map itself. the buzzing graphic right before spawning also feels off, as if it's a compression error that finds it's way.
I've been running clueless about this, until I realised that the bug didn't happen before I updated the pico-8 version.
Is there a solution to this? Or is there a way to downgrade a game's version? (as loading in future versions won't work)
Okay, so I don't know why the pico-8 version matters for this, though I would guess it has something to do with how overflow is handled. However, I'm pretty sure I know what's going with fallenstar.
Your create_life()
function is spawning enemies within a map range that's correct for the x values but goes double the needed y values. Within that extra range you've got a couple pig sprites. From there, the code that applies gravity isn't bounded to a maximum value, so the falling speed can exceed the height of wall tiles. This means that a collision detection algorithm that doesn't do a sweep across the movement vector (most of the ones people use for pico-8 don't) would miss the collisions. On top of all that, a sufficient high value will wrap around to the minimum negative value an keep going.
Thus, what appears to be spawning new enemies is actually the point where the enemies in the wrong part of the map happen to finally detect a collision with the ground.
There's two obvious fixes: 1. change the create_life()
function to not check unnecessary y values or 2. add if(e.dy<5)
in front of e.dy += gravity
, so that enemies can never fall fast enough for this bug to matter.
Ahhh I see!!
Looking at the compressed title art on the map, it starts to make sense now. I had not expected there were entities inside the art. nor would I expect they would fall and overflow.
I'm gonna try fixing it with the first suggestion.
Thanks a lot
[Please log in to post a comment]