Efficiency for item inventory?

0 favourites
  • 3 posts
From the Asset Store
Cartoon Funny Item Interface Sound Pack comes with 426 high-quality sound effects
  • Wagwun fellow developers

    So I'm currently making an inventory system, but I realised that my method may be very inefficient to the performance of the game.

    The general premise of the inventory is that it will be a slot-based system that will be stored via an Array. There will be MANY different items throughout the game that the player can collect, each with their own icon, but the inventory will only display about 16 items at a time.

    The amount of items is definitely going to be 100+. Each icon will have the dimensions 32x32.

    Now how do I display this and make adding items an easy task...


    I have 2 ideas on how to display/create the icons for the items in the Array when I load them

    A) (I'm currently doing this) Have all (100+) item icons of the items in one universal sprite called "Items", and name the animation whatever the item is, and display the animation according to what the item should be.

    B) Create a separate sprite for each and every icon and add it into a universal family and individually code a "create" function for every object (as you cannot "Create object by name", which is why idea A is excellent, due to being able to choose the animation by name).

    Now, I'm thinking that A) would mean that all of the items that exist in the game would be loaded all the time, which wouldn't be too nice on the VRAM. Whereas, B) would only load what is needed (I'm not entirely sure how C2 handles loading stuff)

    However, B) is very long-winded and could potentially be BAD perhaps because there would be 100+ individual sprite objects. But A) Would be all self contained.


    Thanks for reading!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • B is definitely not an option. Your fears with A are valid, however, but since these are all just icons, you will be able to make the image sizes relatively small.

    I'm fairly sure the whole animation is loaded into memory as C2 forms all animations into a sprite sheet, but another option might be separate animations for each icon. I'm not sure how C2 handles this - could we get a statement Ashley?

  • Thanks very much sqiddster, I feel more confident to work with the A) method now :)

    In the universal "Items" sprite, there is lists of animations with just 1 frame for each animation (which is yeah, the icon), and the animation is named after the item (so then I'm able to call it in an event sheet to display the correct item according to what the Array says the item is) and it's doing fine for me, just yeah worried about later on if it might hit the performance. It would really suck if I loaded in 100 odd items then suddenly bam, lag. :P

    I guess the straightforward question is literally "Is having loads of 32x32 icons in one sprite a bad idea?"

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