Log In  


Cart #first_trial-0 | 2025-07-10 | Code ▽ | Embed ▽ | No License


Hey, this is my first time posting, and my first couple of days with pico-8 (and in game dev world)

The game is super simple, I wanted to create a platformer where you walk and collect the healthy mushrooms (one of them fills 20% of the health bar) to survive the road to the village, and you shouldn't mistake the good ones with the poison red and white dotted ones (one of them fills 40% of the poison bar)

The problem I have is that the player goes from 0 to 100 from a single mushroom (or 99 because of the -0.01), when it should go from 0 to 40, so I can go from 40 to 80 if I took another mushroom.

I just get Game Over after collection the first Poison Mushroom... The healthy mushrooms work fine, only adding 20% like I wanted.

Any help would be appreciated, thank you.



It would be most helpful if you post the cart so we can see the behavior in action, or if you don't want to do that, try posting the code in a code block using the three backticks before and after the code (this will make it much easier to read for people trying to help):

--This is what your code block will look like
function _init()
end

Sorry, @2bitchuck, but what are backticks ? In the 45 years I've been coding, that's the first time I've ever heard that term (yup, I'm, that old, I really do need to start getting down and with it and hip with all the cool kids etc)


I don't know if I can type it without triggering the formatting, but it's the character on the same key as the ~ character. Let me see - can I type it? ` Oh, looks like I can!


Ah. The only other character I have on my tilde key(~) is hash(#). I'm guessing its the character on the key beside the "1" key


@2bitchuck Hey, thanks for the comment, I didn't know that these were an option, I'll try to update the post.


@Minion as far as I remember, that is one of the differences between UK and US keyboard layouts.


@nour_m I think the problem is coming in because you're deleting the poison mushroom from the array in the loop and then also adding the same one back to the array at the end of the same loop, so the collision keeps happening multiple times. So the poison value goes 40,80,120 (mid'd down to 100) every time the collision check passes because it's the same mushroom. If your intention is to add a new mushroom when deleting the one you collided with, you'll probably want to construct a new one instead of passing the one you're deleting back to the add_m() function.


@2bitchuck so I need to delete the line for the (delete) and the line for (add) in the poison mushroom part, but what do I do after that?
also, why does the normal healthy mushrooms work even though they have the same code (but +=20 instead of +=40)?


@nour_m Actually, ignore me - I misread your code. You're already doing the thing I said you should be doing, spawning a new mushroom, so my suggestion is not correct.


1

@nour_m Aha, found it! For some reason, all of your poison mushrooms have the same X value, 32. So even when you delete one, the player collides with the other 3 in rapid succession, thus filling the poison meter. So your initial mushroom spawn must be putting all the mushrooms in one spot.


@2bitchuck I have no idea how you realised this, because I didn't write x=32 anywhere in the code. I tried looking and read every line multiple times for hours, nothing... BUT the slots are 32p apart?
That was it, I spawned 10 mushrooms, and I had 6 slots only, the rest (4 mushrooms extra) got assigned to 128, the safe number.
Thank you! It was such an easy fix (added more slots), but I would've never guessed it was a problem if it weren't for your comment.


@nour_m Glad you got it fixed! The way I found it was that I threw a stop() statement into the loop where the collision with the mushroom happens and when the program stopped, I did a print on the X positions of the mushrooms, like print(pmushroom[1].x), print(pmushroom[2].x), etc. I was looking for the one colliding with the player to make sure I was investigating the right thing, but then it turned out that they were all at the same X position and all colliding with the player.



[Please log in to post a comment]