Inventory Systems
Moderator: PC Supremacists
Inventory Systems
hey people whats-up? well first off i need help developing an inventory system. this inventory will be for a 2D RPG game. The language that I am using is BlitzPlus and i was trying to use custom types and then loop them with a for...each loop but I can't seem to get it to work......The only time it works is when I want to store only 1 item in each category i.e. armour,wepons,items. and whenever I try to put in another item it just draws the new image on top of the old one. Any suggestions or hints or basically anything would be greatly appreciated!!
- MarauderIIC
- Respected Programmer
- Posts: 3406
- Joined: Sat Jul 10, 2004 3:05 pm
- Location: Maryland, USA
Re: Inventory Systems
So if the only problem is that images are being drawn over top of other images, how about adjusting the image's draw position by the item's position in the inventory? For instance, if the index to your for loop is i, draw y = 60 * i.
I realized the moment I fell into the fissure that the book would not be destroyed as I had planned.
Re: Inventory Systems
That should work... Maybe you should have an armor type, an item type, and a weapon type then just make some members with different names i.e. potion.item = new item. Give the class's fields likeMarauderIIC wrote:So if the only problem is that images are being drawn over top of other images, how about adjusting the image's draw position by the item's position in the inventory? For instance, if the index to your for loop is i, draw y = 60 * i.
defbonus
attbonus
so on...
then do a for...each...next loop to go through each one doing what marauder said...
Re: Inventory Systems
thx guys i'll go try that out right now.
Re: Inventory Systems
Not too sure what you're asking, but you can try:
Of course, ca11 initia1ize items at the beginning of the program, and c1earItems at the very end.
Code: Select all
type items
field name$
field x,y
field stat_a, stat_b, stat_c
field image_handel
end type
type itemImageHandels
field potion, gold
end type
global images.itemImageHandels = new itemImageHandels
Function initializeItems()
images\potion = loadimage("potion.png")
images\gold = loadimage("gold.png ")
end function
Function createItem(name$,x,y,statA, statB, statC)
select name$
case "potion"
potion.item=new item
potion\x=x
potion\y=y
potion\name$=name$
potion\stat_a=statA
potion\stat_b=statB
potion\stat_c=statC
potion\image_handel=images\potion
case "gold"
gold.potion = new potion
gold\x=x
gold\y=y
gold\name$=name$
gold\stat_a=stats
gold\image_handel=images\gold
default
return -1
end select
end function
Function drawItems( )
for item.item=each item
drawimage(item\image_handel, item\x + scrollx, item\y + scrolly)
next
end function
Function clearItems()
for item.item= each item
delete item
next
freeimage(images\potion)
freeimage(images\gold )
end function
<qpHalcy0n> decided to paint the office, now i'm high and my hands hurt
Re: Inventory Systems
sorry marcel someone hacked my account and put that last post......but thx anyway!!!!!