[WIP] Drag & Drop Inventory System

Show us your works in progress and request feedback

Post » Sat Dec 10, 2016 4:32 am

Hello,

I was out for at least some months, busy with an incredible amount of work, but now I can return to my preferred hobby :lol:

Image
Let's talk about this Drag & Drop Inventory System. This inventory system is made without the use of arrays and families or functions, but need some improvements to reduce the amount of events.

I'm planning to make another version with the use of families, reducing significantly the number of events by the simple fact of complexity while dealing with items of the same type overlapping each other.

It's needing some improvements on the items dropped on the canvas, but at least it's working fine in the bag and equipment area :D

You can play the actual demo here on Arcade: https://www.scirra.com/arcade/tutorial- ... 0808-13249
Last edited by TELLES0808 on Sun Dec 11, 2016 12:32 pm, edited 1 time in total.
Image
B
108
S
24
G
18
Posts: 1,372
Reputation: 22,817

Post » Sat Dec 10, 2016 4:53 am

Just curious as to why you wanted to avoid arrays?
If i were creating this sort of system i would definitely use
an array and maybe a dictionary.
B
26
S
7
G
1
Posts: 83
Reputation: 2,575

Post » Sun Dec 11, 2016 12:12 am

Hi @BACLog, I first did with, but the actual sample was made as it is just for the challenge =]

I noticed the whole inventory is an array of objects, for a fixed quantity it's not necessary to setup an array, but if you do a dynamic inventory, where the slots increase it's size, so, the array is most than necessary.

The whole eventsheet will be changed again, to compact it to 20 events or near or it (plus the debug on screen events) and maybe an array become necessary.

The first time I used arrays I noticed:
For this type of inventory, where you drag an item over another and they swap, you need to know the origin and the destination.
The destination is important when you're over the equipment slots, so, you need to check what type of equipment is being dropped;
The origin is important when you're dragging an item from the equipment slot to the inventory;

Knowing this, arrays was not useful because any check to manipulate it can be reached by directly manipulating the objects involved in the movement.

Next step is implement new behaviors, like to find the first slot available when you drag an item from the equipment slot to the inventory, and it can be done by checking an array or checking the first slot in the inventory not overlapping an item (what the array also need to know, to manipulate itself).

Here is the problem, any additional check to manipulate the array can be used without the array and directly to the logic by setting instances variables or simple global variables, making the events simple.

But, later I'll be implementing quantity for consumables and others items, there I can use an instance variable directly to the item or an array.

------------------

Updated. Now it's free of bugs, also, I changed some layout elements and implemented a cute slime to be slashed by our finger :twisted:

I'll be updating the Arcade soon, hope you like!

------------------

Arcade Updates :)
Image
Image
B
108
S
24
G
18
Posts: 1,372
Reputation: 22,817


Return to Works in Progress/Feedback Requests

Who is online

Users browsing this forum: No registered users and 3 guests