I'd use an array of a type. The type would be called something like TInvSlot (Inventory Slot). Make a field with the img, x, y, width, height, and type pointer TItem type. If the TItem pointer is null then it can recieve an item. If mouse is within the TInvSlot x,y,w,h and mousehit(1) then swap the item pointer from the TInveSlot type to the MousePointer containter type. Or you can just attach an TInvSlot to the mouse pointer by updating the TInvSlot's x,y to MouseX() and MouseY() so the Item Image moves along with the mouse pointer.
Then in the loop see if the mouse is over a slot like this:
Then if the mouse slot is unoccupied transfer the item from the inventory slot to the mouse slot:
I think the inventory is a major part of an rpg and should really be tightly coded and speedy. If it takes me a couple of clicks to get an item to transfer or if the inventory is laggy, I'll just stop playing the game. It's a major pet peeve of mine.
Hope this gives you some ideas!
Type TInvSlot Field x:Int, y:Int, w:Int, h:Int Field item:TItem Method Draw() If self.item <> Null DrawImage item.image, self.x, self.y Endif End Method End Type Type TItem Field image:TImage Method Draw(x:Int, y:Int) DrawImage self.image, x, y End Method End Type Function MouseOver:Int(x%,y%,w%,h%) If MouseX() > x And MouseX() < x + w If MouseY() > y And MouseY() < y + h Return True Endif Endif End FunctionYou would only draw the little item graphic image if it was in a slot. Either the inventory or the mouse slot. That way you don't need xy fields for the TItem.
Then in the loop see if the mouse is over a slot like this:
If MouseOver(slot.x, slot.y, slot.w, slot.h) = True
Then if the mouse slot is unoccupied transfer the item from the inventory slot to the mouse slot:
If MouseHit(1) If invSlot.item <> Null If mouseSlot.item = Null mouseSlot.item = invSlot.item invSlot.item = Null Endif Endif Endif
I think the inventory is a major part of an rpg and should really be tightly coded and speedy. If it takes me a couple of clicks to get an item to transfer or if the inventory is laggy, I'll just stop playing the game. It's a major pet peeve of mine.
Hope this gives you some ideas!