O
Orvais
Guest
Hello!
I'm a bit new to game maker but I've made some decent progress as I've worked on my game, but I hit a bit a brick wall. I was looking inventory systems and found a tutorial from Shaun Spalding which showed the basics on how to make a working inventory system.
What I'm trying to achieve is when I pick up an item, and when you press right or left. it'll shift the whole inventory in that one direction. I made a mock a mock up of what I was trying to achieve.
The large square in the middle is the item that is highlighted at the time when I want to select something.
I'm not exactly sure on how to pull this off, and I've gotten a bit desperate so I made an account to seek some help.
Is there a way to shift every items slot to the next one over to mimic this effect?
Here's the code I'm using from shaun through his guide.
unsure if I need to post anything else to aid me here.
I'm a bit new to game maker but I've made some decent progress as I've worked on my game, but I hit a bit a brick wall. I was looking inventory systems and found a tutorial from Shaun Spalding which showed the basics on how to make a working inventory system.
What I'm trying to achieve is when I pick up an item, and when you press right or left. it'll shift the whole inventory in that one direction. I made a mock a mock up of what I was trying to achieve.
The large square in the middle is the item that is highlighted at the time when I want to select something.
I'm not exactly sure on how to pull this off, and I've gotten a bit desperate so I made an account to seek some help.
Is there a way to shift every items slot to the next one over to mimic this effect?
Here's the code I'm using from shaun through his guide.
Code:
//Create invent
/*
Inventory Items
0 = Sword
1 = Red Potion
2 = Blue Potion
3 = Yellow Key
*/
globalvar showInv; //Display the inventory?
showInv = true;
globalvar maxItems; //total item slots
maxItems = 5;
for (i = 0; i < maxItems; i += 1)
{
global.inventory[i] = -1;
}
Code:
//Draw Event
if (showInv)
{
var x1,x2,y1,y2;
x1 = view_xview[0];
x2 = x1 + view_wview[0];
y1 = view_yview[0];
y2 = y1 + 64;
draw_set_color(c_black);
draw_set_alpha(0.8);
draw_rectangle(x1,y1,x2,y2,0);
draw_set_alpha(1);
for (i = 0; i < maxItems; i += 1)
{
draw_sprite(spr_border,0,x1+24+(i * 40),y2-24)
if (global.inventory[i] != -1)
{
draw_sprite(spr_items,global.inventory[i],x1+24+(i * 40),y2-24)
}
}
}
Code:
//Check Event
for (i = 0; i < maxItems; i += 1)
{
if (global.inventory[i] == argument0) //if slot "i" contains argument 0
{
return(1);
}
}
return(0);