Array Based Inventory

0 favourites
  • 9 posts
From the Asset Store
Supports 1D, 2D, 3D arrays. Import and export arrays in JSON format
  • 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.

  • 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 )

    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 !

  • 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.

  • 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).

  • 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.

  • I'm always trying to improve every weakness of a system of course it looks kinda unrealistic to reach the limit.

  • Hey, it's a nice inventory structure,

    I was led here by looking for stuff about arrays and level building, I thought your capx might be insightful but the link is down

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Sorry about that, old hoster dropped, I believe this is the correct .CAPX

    https://drive.google.com/open?id=15xBDi ... 0eowKkV6IY

  • Thank you so much! Very cool

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)