Hello Everyone. First post. I have been searching the boards and YouTube for a tutorial that might answer the following question, with no success. If anyone has a link to point me to, that might help or someone else has done this please let me know.
Info: The game layout is a sidescroller with a base for player 1 and a base for player 2. I want to have it so if player 1 or player 2 goes back to their base they can press a button and pull up an inventory of items. All items available will be listed, but the player cannot buy said items unless they have enough currency. So what I need are guides on.
1. Inventory. (How do I pull up an inventory box?)
2. Currency. How do I tie currency to the items in inventory?
Any help would be appreciated. I apologize if this has been discussed else where. If that is the case just respond with a link.
I don't know why their aren't any tutorials out their. Inventory is a pretty standard thing. Their is an inventory extension object out their. I found it by using the click team program extensionview.
It might be a good place to start for you. But the object is more of a Data structure for your inventory. Creating graphics that have values that the Data structure can test for isn't automatically created.
So you would still have to create a couple blocks of custom code to talk to your inventory object. You can do it though.
But you probably want to tie the data together in some kind of data structure with a reference to the graphic, the cost and other values the item might need to hold.
As example I would program a 3x3 grid with items numbered 0 til 8. Item zero might cost 200 in game currency points or something like that, store it for instance in an INI object. Do the same for the other items.
Display the items together in a 3x3 grid when the inventory box should come up and hide them when done.
This is just a general idea, the specific implementation of this is up to you. Perhaps try starting out small with a 2x2 grid fro testing and if it works expand it to your liking.
I'd use an array to hold the info about items (including cost), and a global value to keep track of the player's funds. Then when it comes to buying an item, you just compare the two, and if the player has enough money, you deduct the cost and give the player the item. That part is extremely simple.
When it comes to actually handling items in the player's possession, there are a million ways to go about that, so you'd need to be extremely specific about what you want.
eg.
Maybe you want to increase a counter (eg. a clip adds 20 to "ammo").
Maybe you want to replace the player's weapon (eg. the player loses his pistol, but gets a rifle instead).
Maybe you want item slots / squares (eg. a backpack holds up to 10 items).
Maybe you want a weight limit (eg. a rifle weighs 10kg, and the player can carry up to 20kg total).
Maybe you want some items to take up multiple slots / squares (eg. a grenade uses 1 slot; a rifle uses 3 slots).
Maybe you want some items to only go in certain slots / squares (eg. a helmet can only be worn on the head).