Unit 3, Lesson 27: Student Project

I am unable to help a student with is project.

Here is the link:Code.org - Game Lab

Here is the problem:
I’m trying to make an inventory. I have food, walls, fire and other things as variables right now, and they are able to be increased and decreased as you craft, use or mine them. The thing is, I want there to be only 7 different spaces in the inventory. Each has a sprite, and a variable that can be increased if you get more. For example, if you had 5 wood, it would not take up 5 spaces in your inventory, it would have a sprite(image of wood) with the wood count variable number(5) next to it. if I get more categories of items, then the inventory boxes get used up. I want there to be a maximum of 7 different boxes, and if you get a new item, but already have all your boxes filled, the item variable stays at 0. so if you have your boxes filled up, and then you mine wood, you just wouldn’t get the wood, and your wood count variable would still equal 0.

Thank you for any help!!

@tuzupis,

this sounds more like a general question and not a specific question about any of the current code. Can you create a variable (or a group) called inventory? Then, you would have to write code to check the # of items you currently have in inventory. If you tried to add wood, it would first check to see if wood was already in the inventory and if so, it would add to the wood variable. If wood wasn’t in the inventory, it would check how many items were in inventory and if there were 7, it would prevent that item from being added and from having a higher count than 0.

You may want to explore sprite groups. Inventory could be a group that could only contain a maximum of 7 items.

Those are a few general ideas to consider as you keep working on this.

Mike