Item loses it's properties when another spawns

I’m trying to make a game, where when you defeat an enemy, it drops an item. And when there’s only one item that’s spawned, it works fine, but as soon as another item spawns the first item that was spawned doesn’t work anymore and just floats there. I would send the code (and I still might) but it’s a mess at the moment.

2 Likes

Welcome, @OneBigGoof !

There are a few reasons this might be, so you’re right that sending us a link would help greatly. It’s okay if the code is messy, most of us here are used to that. Just go ahead and share the URL for your game and we’ll help debug!

That said, can you tell us more about what you mean when you say “doesn’t work anymore”? What kind of events are you trying to make it respond to?

2 Likes

here’s a link to the code: https://makecode.com/_AA6dTua7E739. I tried to clean it up just a midge, and I put the code that is used for the item spawns with each other so you don’t have to hunt it down. What I was meaning by “doesn’t work anymore” is that, when another item is spawned, the previous item that was spawned before that item stops being able to be touched. It can’t be interacted with or collected and is just a floating sprite.

forgot to mention how the game works. you press A to jump and B to throw rocks. you can step on snakes and bats but for crabs (at least I think they’re crabs?), you have to throw rocks to defeat them.

Alright, I think there are a few things going on here. For example, you have both variables and kinds named “item”. I think that’s causing issues.

Also, can you explain a little more about why you chose to do overlaps this way:
Screenshot 2023-12-05 at 7.05.21 PM
instead of this way?
Screenshot 2023-12-05 at 7.05.29 PM

Personally, I’d also use the sprite data extension to keep track of the properties on these drops. It will make things a lot more simple for you!

1 Like

I think I may have found a fix for it. I may just have to create two different “kinds” for the items. I had tested it to instead just destroy “othersprite” instead of “RockDrop” and it seemed to have worked, since both items stayed and could be interacted with. So I guess now I just have to make a kind for the banana and the rocks.

I had tried to do it with the “on sprite of kind overlaps” block, but it would for some reason cause the previous item to not get destroyed when there were two of the same items in the game, which would cause the game to give the player infinite amounts of that item when touched. So I had tried to do it the same way I did with the enemies, by giving each item their own commands, but it just caused the problem that I’m having now.