• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

GML Inventory for a Drag and drop game. (Gamemaker 2 and GML)

D

Donnyyyyy

Guest
Had to make a game in gamemaker 2 for a school project. But our project needs some kind of Inventory that fits a Drag and drop game. Since im terrible at programming ive had some problems trying to figure out how to actually create a inventory system. Looking for help with finding some kind of tutorial or another thread with the same or atleast similar problem and solution!

What we wanna try to do is get a functioning inventory system. You pick up items by clicking on them and theyre placed in some kind of bar at the bottom. And also being able to drag the items in your inventory to give to NPCs. Does anyone have any idea if this is even possible? And if so how it would be achieved.

Thank you!
 

Yal

🐧 *penguin noises*
GMC Elder
One idea is that the inventory bar is an object: when colliding with the pick-up-able objects, their persistent variable is set to true, so they will follow you around between rooms. (The inventory bar would also be persistent so you don't need to create one copy in every room). All the pickupable items would have a common parent, which has the logic for being dragged around.

That logic could be like this:
There's a variable called FollowMouse.
In step event, If FollowMouse is true, set position to the mouse's. Else don't do anything.
When clicked on (Mouse --> Left Button Pressed), set FollowMouse to true.
When mouse button is released, ANYWHERE on screen (Mouse --> Global Mouse --> Global Left Button Released), set FollowMouse to false.


To also make inventory items return to the inventory if you let go mid-drag, you could add extra logic to make them jump to a free spot in the inventory if you stop dragging when they're persistent, but that gets a bit more complex. Worry about that bit later.
 
N

Nathan Wilson

Guest
FriendlyCosmonaut did a farming rpg tutorial series that may have the inventory system you are looking for.
 

Yal

🐧 *penguin noises*
GMC Elder
Was it drag & drop, though? OP says it needs to "fit a drag and drop game". Not sure if it means the course only allows D&D solutions, the project is D&D, or the game itself has dragging and dropping, but in case it's the first, code solutions might not be allowed (maybe as a way to force people to think/learn instead of just copypasting code from the internet?).
 
D

Donnyyyyy

Guest
Sorry for late reply! Yea looked through the farming rpg, which is more of a Pokemon inventory. (if that makes sense?) Need more of a inventory were you have a inventory bar at the bottom, whilst being able o drag your object in and out of the inventory.
The game is in Gamemaker language! But the game itself is a Drag and drop game, like the Fran bow series. Thank you all for the replies! Ill be trying to work with the help i've gotten so far! But could still need some more help, so dont hesitate to reply haha.
 
I've yet to make a inventory system, but doing a quick google search "gamemaker studio inventory" brings up a lot of videos. I think shuan spalding's video is the one your looking for.
 
Top