Hey all
So i’ve managed to get myself into a situation I can’t quite figure out.
I’m setting up an inventory system, and start by spawning a grid and populating it with square widgets. These all have their own index number.
Adding 1x1 items to the array is easy, I just call the index value itself, check if it is free, and if so I add them in. However adding larger items is more confusing.
I can’t for the life of me figure out how I’d go about checking if the items in 16 + 17, along with 21, 22 and 23 (for a 2x3 item). Has anyone done something similar before. If so do you have any pointers.
Thanks
For a 7x6 array starting at index 0 and column being the slowest:
*Test it thoroughly:
Hope it helps.
Thanks for this. I’ll give it a shot and see what I can do with it.
For anyone googling this in the future, I ended up swapping my Array out for a Map, storing both a Vector 2d with the X + Y coords and then a reference to the item square I wanted to show.