So I'm trying to get back into the swing of things after a long absence, and in a new little project I'm working on I am trying to create an inventory system where some equipment takes up more than one space. Much like Diablo II, Path of Exile, Adventures of Van Helsing and so on have done... But I am a bit stumped on the best approach.
I've done plenty of slotted inventories, but single slot consumption is a lot easier since its just a little looping and some lists then a few screen locs and you're set.
In this one I'm using 45 slots spread over a 9 by 5 32x32 slotted inventory. I've considered making each one a variable, and going over them but that seems messy. I'm also interested in drag and drop rearranging which further complicates it. I could try a list for each row or column but then they all interact too much in drag and drop.
Anyone got some ideas that might help me get started in the right direction?
Jun 12 2018, 11:54 am
|
|
Don't all you have to do is handle item stacking procedures upon item pickup -- e.g. if item A is not stackable, then immediately move it to the player's inventory list, otherwise add its quantity to any existing items of the same type if applicable -- then go through the player's inventory list and plot the items on the screen?
|
For item stacking, yes. But for what I am looking to do you would have cases like for example... A sword might take up three spaces vertically on screen, an armor might take up a 2x2 square (4 32x32 boxes), a potion only one space, and so on.
|
Ah.
I wrote a rough idea of what came to mind for this. Disclaimer: This is a personal first and written off-top. At best, I would use this to get an idea of how to approach it yourself, as there is much room for improvement. mob I didn't jump into any drag/drop stuff, but I imagine that part would be simple once you decide on your core. It's been a minute so maybe you've found some clarity by now (do share if so). This seems to be mostly a question of approach though, so while one side of me would say there is no "right" answer, the other side would suggest the "right" answer is what works for you now and going forward. |
Well it'll definitely take some trial and error. I'm working on fixing a bad index runtime error in has_open_slots and working out a display before diving into improvement and ironing it out. Solid start point though, which is what I needed; so thank you!
Once I get everything set up right I'll probably post up the final version to help anyone else that attempts this along the way. |