Inventory Systems

Anything related in any way to game development as a whole is welcome here. Tell us about your game, grace us with your project, show us your new YouTube video, etc.

Moderator: PC Supremacists

Post Reply
spum
Chaos Rift Newbie
Chaos Rift Newbie
Posts: 39
Joined: Tue Dec 23, 2008 10:41 pm

Inventory Systems

Post 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!!
User avatar
MarauderIIC
Respected Programmer
Respected Programmer
Posts: 3406
Joined: Sat Jul 10, 2004 3:05 pm
Location: Maryland, USA

Re: Inventory Systems

Post 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.
I realized the moment I fell into the fissure that the book would not be destroyed as I had planned.
User avatar
eatcomics
ES Beta Backer
ES Beta Backer
Posts: 2528
Joined: Sat Mar 08, 2008 7:52 pm
Location: Illinois

Re: Inventory Systems

Post 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...
Image
spum
Chaos Rift Newbie
Chaos Rift Newbie
Posts: 39
Joined: Tue Dec 23, 2008 10:41 pm

Re: Inventory Systems

Post by spum »

thx guys i'll go try that out right now.
User avatar
Arce
Jealous Self-Righteous Prick
Jealous Self-Righteous Prick
Posts: 2153
Joined: Mon Jul 10, 2006 9:29 pm

Re: Inventory Systems

Post 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.
<qpHalcy0n> decided to paint the office, now i'm high and my hands hurt
spum
Chaos Rift Newbie
Chaos Rift Newbie
Posts: 39
Joined: Tue Dec 23, 2008 10:41 pm

Re: Inventory Systems

Post by spum »

sorry marcel someone hacked my account and put that last post......but thx anyway!!!!!
Post Reply