I've been spending a long time trying to get this working and I always seem to run into a problem. I'm not even sure if it's possible to stack items into an inventory with the way I've made my game but here's what I've figured out so far:
I create an array and tiled background for the inventory. When I run into an item I pick it up and then I start a loop. The loop basically goes through each spot in the array and looks for an empty space to place the item.
Everything up to this point works great but I can't get the picked up item to recognize when I already have the same item in my inventory. I want to make it so that:
-There can be multiple stacks of an item type with a maximum amount of the item in each stack. (So if I want a stack of bullets the max in one stack can be 10)
-The picked up item goes to the smallest stack.
-Shooting a bullet, for example, will take away one item from the stack (assuming the stacked item is a bullet).
Is this even possible using just an array or am I just driving myself crazy?