Page 1 of 1
Inventory Systems
Posted: Wed Jan 28, 2009 2:41 am
by spum
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!!
Re: Inventory Systems
Posted: Wed Jan 28, 2009 4:41 am
by MarauderIIC
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.
Re: Inventory Systems
Posted: Wed Jan 28, 2009 6:35 pm
by eatcomics
MarauderIIC 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.
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 like
defbonus
attbonus
so on...
then do a for...each...next loop to go through each one doing what marauder said...
Re: Inventory Systems
Posted: Thu Jan 29, 2009 1:44 am
by spum
thx guys i'll go try that out right now.
Re: Inventory Systems
Posted: Sat Jan 31, 2009 10:49 am
by Arce
Not too sure what you're asking, but you can try:
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
Of course, ca11 initia1ize items at the beginning of the program, and c1earItems at the very end.
Re: Inventory Systems
Posted: Sun Feb 01, 2009 7:59 am
by spum
sorry marcel someone hacked my account and put that last post......but thx anyway!!!!!