How do I create a Diablo Inventory?

0 favourites
  • 5 posts
From the Asset Store
Fully commented source code/event sheet & sprites to create a space shooter game
  • Hi everyone,

    any idea on how I can create a Diablo Inventory?

    I would like to be able to create several size of items that can fit in more than one cell / inventory slot.

    For example, imagine that you have tetris shapes and you need to store them in an inventory?

    What would be the best solution?

    Thank you

  • If the size of the inventory is of a reasonable size, I would probably use a brute force guess and check method. Each item of any size should have a "base" tile, for example the top left corner. Then when placing the item in in inventory array, check each additional spot that item requires to fit, and only proceed if all required spots are valid.

    For auto fitting on pickup, you would loop each available slot in the inventory starting with the base tile and checking for validity until it fits or fails.

    Each item should have instance variables to describe it's size either in terms of array positions, or width and height of all items are rectangular.

  • Thanks oosyrag

    "Then when placing the item in inventory array, check each additional spot that item requires to fit, and only proceed if all required spots are valid."

    this is what I was thinking but I don't know how to achieve this :)

  • In your array, you can use a 1 or 0 in each cell to represent if that slot is filled or empty. Check each cell that the item wants to go in and only proceed if all cells are empty.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • thanks, will try this :)

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