• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

3 slot inventory

M

mr_starfire

Guest
Hi guys i want to create a small inventory with only 3 slots will i still need to use arrays to do this ?
 
Z

zendraw

Guest
well what are you gona put in that inventory, how will you use it. anything is possible there is no universal law that inventorys are made with arrays.
 
S

Salvakiya

Guest
you do not need an array to make any kind of inventory. its just the easy/convenient way to do it. you could easily just use 3 variables.

slot0 = noone;
slot1 = noone;
slot2 = noone;

however that means you have to program behavior for each slot. That is unless you had an inventory slot object which you tied to each variable. it just over complicated things. besides it does not look much different from

slot[0] = noone;
slot[1] = noone;
slot[2] = noone;
 
M

mr_starfire

Guest
yh i guess you are right my inventory is going to be very similar to a inventory in a game called dizzy from the 80s

<<holy hell i loved this game as a kid>>

i want the same mechanic as the inventory shown where as the item in the first slot gets moved up by one slot every time the player attempts to pick something up and if its in the final slot when the attempt is made that item gets dropped
 
Z

zendraw

Guest
well just make it an array and when you pick up do somthing like this

if item[2]>0 instance_create(x, y, item[2])
item[1]=item[2]
item[0]=item[1]
other=item[0] //other is the object you are picking

the code most likely wont look like this but you get the idea.
 
M

mr_starfire

Guest
im trying multiple options at the moment this one being one of them thanks ill keep you posted and thanks again
 
Top