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/
Xem thêm Bài Viết:
- Game bắn cá mobile – trò chơi kiếm tiền thưởng nổi tiếng tại Dabet
- Are You Sleeping (Brother John)? – Amazing Songs for Children | LooLoo Kids
- We got into a SILVER matchmaking game (sub games)
- CONAN EXILES : SUMMONING AVATAR GODS TUTORIAL GUIDE – How to spawn GODS
- Five Nights at Freddy's 3 Game Maker Edition
I have errors, code doesn't know what view_xview and the other 2 views are
It;s not working for me 🙁
working in gamemaker 2 and the 'draw the 'simple' rectangle took me wayyyy too long XD
'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.
Remember when skype was a thing
in game maker 2 what is the code for view_xview? becase doesnt exist any more
heads up! use ds_lists instead of arrays for much more convenient and faster creation – gamemaker doesn't implement arrays very well
your still a great teacher
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.
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
does this work in gms2?
Now you can use arrayname = array_create( numOfSlots , defaultValue );
to set all the numbers to -1 (or any other)
Any way to get the project file up again?
MaKiNg GaMeS iS eAsIeR tHaN yOu ThInK — demy, u, 2018
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
0:59
Can't download project files anymore?
Can you make the tutorial about hand slot? xD
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;
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?
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
It said on my game maker that I have too many objects
Is there a way to make the inventory scale to the size of a view?
why did you choose to return 1 and 0 instead of returning true and false?
ARRRRGHHH I wish I watched this sooner!!!
I spent too much time typing global. before WAY TOO MUCH
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?
The script doesn't work for me, it only puts an item in the first slot nowhere else. Could someone help?