Array Based Inventory

Show us your works in progress and request feedback

Post » Sun Mar 27, 2016 10:54 pm

So this is something I have been messing with. It's an Array based inventory that is created and destroyed every time it is opened or closed to save on memory usage. I made it in the style of the Terraria Inventory because that is one of my favorites. So far you can pick up items it keeps track of them how many of each you have. You can click and move items around in the inventory. The next feature I will add is the ability to drop items. Then after that I want to move onto a crafting system which should be fun. Link to check it out below as well as the .capx if anyone wants to poke around and see how it works or use it in their game.

CONTROLS
WSAD-MOVE
TAB- Toggle Inventory
LEFT CLICK- Select item in inventory to move it.

Game Link
https://dl.dropboxusercontent.com/u/729 ... index.html
.CAPX Link
https://dl.dropboxusercontent.com/u/729 ... ntory.capx

If you have clicked on the link before you may have to refresh once you get to the game to the get the most recent build.

If you mess around in the .CAPX and are able to streamline the code or fix any redundancies please let me know so I can make it more efficient.
Last edited by VictoryX on Mon Mar 28, 2016 5:13 pm, edited 1 time in total.
Image
B
45
S
17
G
2
Posts: 201
Reputation: 4,471

Post » Mon Mar 28, 2016 11:49 am

I only did a test on the web and it is very cool !
Be careful of text placement which is randomly placed when you are hover an object, make it being at the top-right corner (or wherever you want) all the time.
It will be more user-friendly, because you eye do less effort to know where the information will be shown (yes, it looks like a detail but ppl work on things like that :D )

Now, why destroying and creating it all the time ? It means you will increase UID all the time, when u can only show/hide a global layer ?
I'm not sure it is the best way to do that. If you disable everything around your objects (collision, no behavior...) and add your objects on a layer with a parallax (0,0) you will have a very efficient program. It's how i would do it if i had to.

Thanks for sharing !
B
13
S
5
G
1
Posts: 138
Reputation: 2,659

Post » Mon Mar 28, 2016 5:11 pm

Thank you very much for the feedback. I updated the Item name so it always pops up in the same spot now for the item you are hovering in your inventory. I also added a remove item feature. If you have an item selected and click outside of the inventory area it will drop the item into the world. It should also track the amount of the dropped item so if you drop 10 rocks when you pick it back up you will get 10 rocks. I went for the create/destroy method because later on I figure there will be a lot of stuff on screen and I didn't want an inventory of items taking up memory while being un-used. You are correct about the UID increase, but I never use the UID to track stuff anyways.
Image
B
45
S
17
G
2
Posts: 201
Reputation: 4,471

Post » Tue Mar 29, 2016 10:05 pm

It's not because you don't use it that it doesn't exists :p
UID is a system data used by Construct, you can't change the main way it works.

Your test shows objects are always created/destroyed (when you drag them on the floor, when you take them back)
Of course if you think with a minimalist view, it's okay to do that.

Now think that i'm working on a simple graphic game, 20 levels, 800 objects. If you do a RPG how many things will be added/destroyed all the time ? Yes, much more than 800.
If you use Background to draw your inventory boxes + your objects it wont take that much memory.

There is a memory limit to create and destroy all the time, that's why i'm talking about it and asking you.
Of course it's millions of objects, but the limit exists. It's the size of an Int (Google it if you need it).
B
13
S
5
G
1
Posts: 138
Reputation: 2,659

Post » Tue Mar 29, 2016 11:45 pm

The limit is so large and at max by closing and opening the inventory you create 120 new UID's based on all the slots, an item in every slot, and each item there is a multiple so you get the number count. They would have to open and close the inventory millions and millions of times before reaching that limit. Even with every other object in the game you have to be creating something seriously massive to ever reach that limit.
Image
B
45
S
17
G
2
Posts: 201
Reputation: 4,471

Post » Thu Mar 31, 2016 6:43 pm

I'm always trying to improve every weakness of a system ;) of course it looks kinda unrealistic to reach the limit.
B
13
S
5
G
1
Posts: 138
Reputation: 2,659


Return to Works in Progress/Feedback Requests

Who is online

Users browsing this forum: No registered users and 0 guests