Version 2.0
What did I do?
I remade the asset from scratch, taking previous feedback into account, as well as adding another feature (persistent saving/loading of containers/floor items between rooms).
The actual use of the asset should be familiar if you used previous versions, it's just what's under the hood that's different.
I added a second room + a warp object in both for movement between rooms (WASD controls the player). This was mainly to test that the saving/loading was working properly.
There is a note called _MANUAL_readme inside the asset which has information on how to add new things as well as information I thought you might like to know.
The performance of open containers should be greatly increased as now a single surface for each open inventory is used.
Reducing Complexity
I tried really hard to reduce how complex the code is, and if you read the manual, it should be very straight forward for how to create/add new items and containers.
I was unable to reduce the code complexity in some areas. Eg I tried to have the item sprites use a middle-centre origin, because that would make calculating rotation easier, but then when it comes to checking relative rectangles (where is the mouse item in the room vs the container it's over + all of that containers existing items) it was just more complex than if I went with a top-left origin for items, so I ended up going with top-left.
I could not completely eliminate the use of double for loops to check whether there was a free space inside a container/inventory so items have 2 sets of coordinates
1) Rectangle : this is used when a player has an item in the mouse, and is checked to see if where the player is trying to place that item is free or not.
2) Cell Coordinates : an inventory starts with coordinates of 0,0 in the top left, and the item cell coordinates reflect the top left and bottom right positions that the item takes up in the inventory. If an item is added to a container by generation (eg when it's first opened) or the player is trying to place the item inside the container but the position is not free, these coordinates will be used along with a double for loop to try and place the item automatically for the player.
It's really this area that I think people will wtf about and among all my research I didn't find a method that I thought i could use / code myself. Histograms looks promising but doesn't take into account inventories that can have items all over the place.
Ideally I'd have code that would automatically break up an inventory into available rectangles every time an item was added/remove, and then we'd have an array of free rectangles to check against, but I havent gotten that far yet sorry :D
Files
Get Diablo-style Inventory
Diablo-style Inventory
Diablo-Style Inventory System
Status | On hold |
Category | Assets |
Author | GameMaker Rob |
More posts
- Small BugfixMay 18, 2023
- Current ProgressNov 05, 2022
- Optimization (in progress)Sep 26, 2022
- Update v1.2Mar 01, 2021
- Bugfix v1.1Dec 05, 2020
- FAQ/How do I use this asset?Nov 05, 2020
Leave a comment
Log in with itch.io to leave a comment.