drag and drop to screen

Discussion in 'Programming' started by phillipPbor, Jul 2, 2016.

  1. phillipPbor

    phillipPbor Member

    Joined:
    Jun 21, 2016
    Posts:
    223
    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 :)
     
  2. Aura

    Aura Guest

  3. phillipPbor

    phillipPbor Member

    Joined:
    Jun 21, 2016
    Posts:
    223
    hes not responding...
    and anyone help with an invantory?
     
  4. ShaunJS

    ShaunJS Just Another Dev GMC Elder

    Joined:
    Apr 12, 2016
    Posts:
    148
    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.
     
    hippyman likes this.
  5. phillipPbor

    phillipPbor Member

    Joined:
    Jun 21, 2016
    Posts:
    223
    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?
     
  6. ShaunJS

    ShaunJS Just Another Dev GMC Elder

    Joined:
    Apr 12, 2016
    Posts:
    148
    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.
     
  7. phillipPbor

    phillipPbor Member

    Joined:
    Jun 21, 2016
    Posts:
    223
    do you think we can make a tutorial?
     
  8. ShaunJS

    ShaunJS Just Another Dev GMC Elder

    Joined:
    Apr 12, 2016
    Posts:
    148
    That's not something I'm working on at the moment, no. Sorry!
     
  9. hippyman

    hippyman Member

    Joined:
    Jun 20, 2016
    Posts:
    565
    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.
     
    ShaunJS likes this.
  10. phillipPbor

    phillipPbor Member

    Joined:
    Jun 21, 2016
    Posts:
    223
    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)
     
  11. YanBG

    YanBG Member

    Joined:
    Jun 25, 2016
    Posts:
    597
    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.
     
  12. phillipPbor

    phillipPbor Member

    Joined:
    Jun 21, 2016
    Posts:
    223
    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.
     
  13. YanBG

    YanBG Member

    Joined:
    Jun 25, 2016
    Posts:
    597
    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
                }
            }
        }
    }
     
  14. phillipPbor

    phillipPbor Member

    Joined:
    Jun 21, 2016
    Posts:
    223
    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.
     
  15. Xer0botXer0

    Xer0botXer0 Member

    Joined:
    Jun 29, 2016
    Posts:
    675
    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: Jul 7, 2016

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice