drag and drop to screen

phillipPbor

Member
I have Shawn's formula of inventory seted up to get started on the first person myst game engine. but I got one question, if the inventory is for dragging and dropping items. would it be dropped onto the background screen?

like: If you found the key and clicked on it, it would pop into your inv, and if you click drag and drop onto the door. it destroys key and changed the door to open.

please PM Shawn this question please? thank you :)
 

ShaunJS

Just Another Dev
GMC Elder
It's not really possible for me to provide one to one support for my tutorial videos. That'd be a full time job for like, a team of three.

I made that video a while ago I can't remember the whole process.

That and I'm not sure what the question means at all.
 

phillipPbor

Member
It's not really possible for me to provide one to one support for my tutorial videos. That'd be a full time job for like, a team of three.

I made that video a while ago I can't remember the whole process.

That and I'm not sure what the question means at all.
the question is that if you had an inventory, would you unlock doors by draging and dropping keys on them?
would be posible that door object knows if its a key or not?
and is it possible that you use object items instead of sprites? how do you do it?
 

ShaunJS

Just Another Dev
GMC Elder
Are you just asking if it's possible to write code, using the inventory system I made a video on, that allows you to drag an object on to another object, remove that item from the inventory and perform an effect?

Yes, very possible. There's all kinds of ways of doing these things and the system I wrote was very simple and bare bones to allow as much flexibility as possible. When dragging an item it's tracked by a variable (if I remember correctly) so just check that variable when letting go of the item within a certain region. How you approach this specifically step-by-step depends on your set up.
 

phillipPbor

Member
Are you just asking if it's possible to write code, using the inventory system I made a video on, that allows you to drag an object on to another object, remove that item from the inventory and perform an effect?

Yes, very possible. There's all kinds of ways of doing these things and the system I wrote was very simple and bare bones to allow as much flexibility as possible. When dragging an item it's tracked by a variable (if I remember correctly) so just check that variable when letting go of the item within a certain region. How you approach this specifically step-by-step depends on your set up.
do you think we can make a tutorial?
 

hippyman

Member
do you think we can make a tutorial?
At a certain point you need to learn not to rely on tutorials.
Consider times like these a challenge. Look at the task thoroughly and play it out step by step in your head how you need to accomplish it.
You really start to learn things when you start to do them on your own. Of course at the start it's going to most likely be terrible. We ALL went through it. Eventually you'll begin to write better, more optimized code as you learn things that do and don't work.
And as long as you stick with it and don't give up, before you know it, it will feel like second nature and issues like these will be a breeze to you.
 

phillipPbor

Member
it is hard, i think i need help.

/*
Inventory Items
0 = Sword
1 = Red Potion
2 = orange Potion
3 = Yellow Potion
4 = green Potion
5 = cyan Potion
6 = blue Potion
7 = purple Potion
8 = key
*/
globalvar showInv; //Display the inventory?
showInv = true;
globalvar maxItems; //total item slots
maxItems = 10;
for (i = 0; i < maxItems; i += 1)
{
global.inventory = -1;
button = instance_create(0,0,obj_invbutton)
button.slot = i;
}
globalvar mouseItem;
mouseItem = -1;
instance_create(0,0,obj_mouseitem); (if we need to make this object. with an obj instead of sprites)
 

YanBG

Member
You should provide the video and the code, like you did now.

Are the dropped items on the ground objects? If the key and the door are objects, you can add a collision event for one of the them with the other and make the door destroy itself.
 

phillipPbor

Member
You should provide the video and the code, like you did now.

Are the dropped items on the ground objects? If the key and the door are objects, you can add a collision event for one of the them with the other and make the door destroy itself.
have you played first person point and click adventure games? i made an object that you can drag it, when you release the button, it jumps back to position.
 

YanBG

Member
Yes i did, if they are objects you have a lot of possibilities to register the drop(e.g. both objects sprites touch each other), all instance_xxxxx functions, because you work with instances of the objects, or even bbox_xxx(top, down etc borders of object's sprite in room coordinates).

But seems that you mean an object(like it's the same for any items, not a key object itself?), assuming that it draw a sprite:

In the Door object, create action Mouse->Left Released and write this code
Code:
if(instance_exists(obj_mouseitem){
    with(obj_mouseitem){
        if(key=true&&collision_rectangle(bbox_left,bbox_top,bbox_right,bbox_bottom,other.id,false,true)){
            if(other.open==false){//variable in obj_door to switch from close to open
                other.open=true;
                key=false;//you need a way to delete the key here
            }
        }
    }
}
 

phillipPbor

Member
Yes i did, if they are objects you have a lot of possibilities to register the drop(e.g. both objects sprites touch each other), all instance_xxxxx functions, because you work with instances of the objects, or even bbox_xxx(top, down etc borders of object's sprite in room coordinates).

But seems that you mean an object(like it's the same for any items, not a key object itself?), assuming that it draw a sprite:

In the Door object, create action Mouse->Left Released and write this code
Code:
if(instance_exists(obj_mouseitem){
    with(obj_mouseitem){
        if(key=true&&collision_rectangle(bbox_left,bbox_top,bbox_right,bbox_bottom,other.id,false,true)){
            if(other.open==false){//variable in obj_door to switch from close to open
                other.open=true;
                key=false;//you need a way to delete the key here
            }
        }
    }
}
so? its the only way I did.
but did you know that you can Rclick on the item that you can interact with them?
and to delete the key (here), my that's a tricky one. it takes brain but doubt that ever work if none.
 

Xer0botXer0

Senpai
What are you trying to do ?

"If the inventory is for dragging and dropping items".
What does the video show you ? have you duplicated the code to test it ?


Are you trying to create an inventory, and if so with what features ?
How does the inventory open up and close
How are inventory items loaded, how are they displayed
what information is displayed
how does one interact with the inventory objects
what will those interactions be
how will having an inventory open during gameplay effect other code within your game

I understand what you mean by this key, you want to open up the inventory, click on a key(in this case) and drag it into the game world, dragging it onto a door to unlock the door then destroy the key.

is this what you're trying to accomplish ? I suppose you're having difficulties identifying the door that the key's being used on, and the key being the correct key for that door.
 
Last edited:
Top