Game

Game Maker Studio: Inventory Tutorial



If you like what I do, please consider supporting via Patreon!

Download the project files!

This is a big one! A lot of this tutorial was based on a lecture I gave on similar topics at Teesside University. The idea is to show you the fundamentals behind setting up almost any kind of inventory system using Arrays to store items, how to go about drawing it to the screen and how to use scripts to add, remove and check for items in the inventory.

I recently released a game on Steam that I built with GM:Studio!

Nguồn: https://jacarandarmfm.com/

Xem thêm bài viết khác: https://jacarandarmfm.com/game/

27 Comments
  1. Chad Hinkley 9 months ago
    Reply

    I have errors, code doesn't know what view_xview and the other 2 views are

  2. John Perez 9 months ago
    Reply

    It;s not working for me 🙁

  3. OctopusIncus 9 months ago
    Reply

    working in gamemaker 2 and the 'draw the 'simple' rectangle took me wayyyy too long XD

  4. James Benson 9 months ago
    Reply

    'view_xview[0]' doesn't exist in game maker… Stay yellow when use that function… And I can't find no other to make the inventory follows the camera.

  5. KipperSkipp 9 months ago
    Reply

    Remember when skype was a thing

  6. Matias F 9 months ago
    Reply

    in game maker 2 what is the code for view_xview? becase doesnt exist any more

  7. dconn 9 months ago
    Reply

    heads up! use ds_lists instead of arrays for much more convenient and faster creation – gamemaker doesn't implement arrays very well

  8. johnblur jmc50 9 months ago
    Reply

    your still a great teacher

  9. Nelson Denure 9 months ago
    Reply

    I made an inventory, and everything works until I enter a room with a camera. The slots always are made in the upper left but the sprites/images are where they should be. If I were in one of these rooms, I have to go into the upper corner to access my inventory.

  10. Bailey Long 9 months ago
    Reply

    this is a nice system but not great when working with lots of items. Anyway you can make it so that The image in the inventory can be from different sprites rather than just sub images from one sprite

  11. punkfruit 9 months ago
    Reply

    does this work in gms2?

  12. Schoko4craft 9 months ago
    Reply

    Now you can use arrayname = array_create( numOfSlots , defaultValue );
    to set all the numbers to -1 (or any other)

  13. Misanthrope Man 9 months ago
    Reply

    Any way to get the project file up again?

  14. Gustavo Miler 9 months ago
    Reply

    MaKiNg GaMeS iS eAsIeR tHaN yOu ThInK — demy, u, 2018

  15. Whatever&Stuff 9 months ago
    Reply

    if you want a script to physically drop the items from your inventory back onto the ground, I made something like this.

    If you have followed through and understood shauns video you should be fine with this, It is basically a script to reverse the process. I start by defining the object variables (you can skip this step by adding the object name directly to the instance_create). This script should be called in a key released event, call it scr_item_drop() or something. I then had to duplicate the script to check for each object in my game… There is probably a much better way of doing this but works all the same.

    //INVENTORY ITEMS

    i0 = o_fuel; //fuel
    i1 = o_health_pack; //healthpack
    i2 = o_component; //component
    i3 = o_ice; //ice
    i4 = o_multitool; //multitool

    //——————————————————-//
    //Item Drop
    //—————————————————–//

    for (i =0; i < global.maxItems; i+=1)
    {

    if (global.inventory[i] != -1) //if slot i is not empty
    {
    //Check if fuel in inventory and drop
    if (global.inventory[i] == 0)
    {
    global.inventory[i] = -1;
    instance_create(x,y,i0)
    }

    //Check if medpac in inventory and drop
    if (global.inventory[i] == 1)
    {
    global.inventory[i] = -1;
    instance_create(x,y,i1)
    }

    //Check if component in inventory and drop
    if (global.inventory[i] == 2)
    {
    global.inventory[i] = -1;
    instance_create(x,y,i2)
    }

    //Check if ice in inventory and drop
    if (global.inventory[i] == 3)
    {
    global.inventory[i] = -1;
    instance_create(x,y,i3)
    }

    //Check if multitool in inventory and drop
    if (global.inventory[i] == 4)
    {
    global.inventory[i] = -1;
    instance_create(x,y,i2)
    }

    return(1);
    }

    }

    return(0) //If there were no items in slots return 0 and stop script

  16. ALPHA Games Oficial 9 months ago
    Reply

    0:59

  17. AllFenom 9 months ago
    Reply

    Can't download project files anymore?

  18. BokiXtreme 9 months ago
    Reply

    Can you make the tutorial about hand slot? xD

  19. MaxVilocity 9 months ago
    Reply

    if you are using gamemaker studio 2 then heres what you have to put(make sure the camera has nothing to do with it)
    x1=0;
    x2=(your rooms max width);
    y1=0;
    y2=200;

  20. Sophia 9 months ago
    Reply

    I know this is a reaally old video, but the items I add to my inventory keep repeating. I added return(1), how do I fix it?

  21. BaerliderFuch 9 months ago
    Reply

    The Tutorial is goos, but i hate the Fact that you don't show your game, i don't know if it is worth following this 40 minute long video if i don't even know the result

  22. Rex Okami 9 months ago
    Reply

    It said on my game maker that I have too many objects

  23. Dstails Gaming 9 months ago
    Reply

    Is there a way to make the inventory scale to the size of a view?

  24. David Page 9 months ago
    Reply

    why did you choose to return 1 and 0 instead of returning true and false?

  25. Mister Omegonnaise 9 months ago
    Reply

    ARRRRGHHH I wish I watched this sooner!!!
    I spent too much time typing global. before WAY TOO MUCH

  26. Pons 9 months ago
    Reply

    I have a little problem. I implemented this in a test RPG project, and the Inventory is drawn under some objects in other layers (obvsly that layer is under the layer i put the nventory object). Anyone help me?

  27. Dan Slash 9 months ago
    Reply

    The script doesn't work for me, it only puts an item in the first slot nowhere else. Could someone help?

Leave a Comment

Your email address will not be published.

You may also like