The Daily Click ::. Forums ::. Klik Coding Help ::. Hidden Object Game/Adventure Game Inventory System
 

Post Reply  Post Oekaki 
 

Posted By Message

vetmora120



Registered
  07/01/2010
Points
  273
21st February, 2011 at 13:01:01 -

So I've made a pretty promising inventory system for a hidden object game. It has a set amount of slots and when an object is acquired the object is placed in the first available slot.

However my problem is: When an object is selected from the inventory and used/taken out, I can't get the object that are after that slot to move down to 'fill in the gap'. I am using an array to store the object data and position in the inventory.

Any help would be appreciated.

 
n/a

Assault Andy

Administrator
I make other people create vaporware

Registered
  29/07/2002
Points
  5686

Game of the Week WinnerVIP Member360 OwnerGOTM JUNE - 2009 - WINNER!GOTM FEB - 2010 - WINNER!	I donated an open source project
21st February, 2011 at 14:51:54 -

You'll probably have to explain how your inventory system works, or provide an example file so that we have a better idea.

Simple (but perhaps inefficient) systems that come to mind are:

Loop through the array and write it to a new array in the same order, skipping gaps.
Or
Loop through the array starting at the gap and shift each object down 1.

It really does depend how you store your information.

 
Creator of Faerie Solitaire:
http://www.create-games.com/download.asp?id=7792
Also creator of ZDay20 and Dungeon Dash.
http://www.Jigxor.com
http://twitter.com/JigxorAndy

vetmora120



Registered
  07/01/2010
Points
  273
22nd February, 2011 at 01:58:27 -

Thanks for the reply Andy. I've posted the example link below so you can see how it works. It's probably not the most efficient way of making an inventory system, but it's what I came up with

http://dl.dropbox.com/u/9919361/InventorySystem.mfa

 
n/a

Alonso Martin



Registered
  29/12/2010
Points
  294
22nd February, 2011 at 02:09:32 -

Sometimes, I tried making an inventory system like Monkey Island's. I realised using the Text Blitter as a graphic placeholder made things infinitely easier.

 
www.hfalicia.com
www.alonsomartin.mx

vetmora120



Registered
  07/01/2010
Points
  273
22nd February, 2011 at 06:33:46 -

I've never thought of using the Text Blitter before. Might give that a go sometime. But for now, is anyone able to tell me how to achieve the gap filling with the system I've done?

Thanks in advance.

Edited by vetmora120

 
n/a

UrbanMonk

BRING BACK MITCH

Registered
  07/07/2008
Points
  49566

Has Donated, Thank You!Little Pirate!ARGH SignKliktober Special Award TagPicture Me This Round 33 Winner!The Outlaw!VIP MemberHasslevania 2!I am an April FoolKitty
Picture Me This Round 32 Winner!Picture Me This Round 42 Winner!Picture Me This Round 44 Winner!Picture Me This Round 53 Winner!
23rd February, 2011 at 04:54:26 -

http://jfile.us/a3d47ed

I redid the inventory system from scratch.

It's on the second frame.

It doesn't use an array at all.
You should be able to figure out how it works.

 
n/a

vetmora120



Registered
  07/01/2010
Points
  273
23rd February, 2011 at 07:12:19 -

Hey, thanks UrbanMonk. That's pretty neat. Still figuring out exactly how you've done it, but I think I've got a basic grasp.

One question though. How then would I save and load the inventory using the information I've got?

Edited by vetmora120

 
n/a

UrbanMonk

BRING BACK MITCH

Registered
  07/07/2008
Points
  49566

Has Donated, Thank You!Little Pirate!ARGH SignKliktober Special Award TagPicture Me This Round 33 Winner!The Outlaw!VIP MemberHasslevania 2!I am an April FoolKitty
Picture Me This Round 32 Winner!Picture Me This Round 42 Winner!Picture Me This Round 44 Winner!Picture Me This Round 53 Winner!
23rd February, 2011 at 13:13:34 -

I would save it using an ini, but you can use whatever method you like.

It's easy, when you're ready to save the inventory do another loop, similar to the one that refreshes the inventory.

Iterate through the objects and save their direction and alterable string. Then to reload it just recreate the objects with the appropriate values and run the refresh inventory loop to put them in the inventory.

If you want I'll add loading and saving sometime today when I get time.

 
n/a

vetmora120



Registered
  07/01/2010
Points
  273
23rd February, 2011 at 13:48:41 -

Ah ok, that makes sense. If you don't mind though would you be willing to add a system in for me? Also an extra thing to put in something so that objects don't appear again in game when they've been obtained and used, etc.? That's only something extra though.

Thank you for all your help. I learn from the best

 
n/a

Del Duio

Born in a Bowling Alley

Registered
  29/07/2005
Points
  1078

GOTW WINNER CUP 1!GOTW WINNER CUP 2!GOTW WINNER CUP 3!GOTW WINNER CUP 4!Evil klikerHasslevania 2!The OutlawSanta Boot
23rd February, 2011 at 14:00:47 -

I did something where the inventory items' names were all held in a listbox off the frame, and when you took one out they all automatically resorted and "fill in the gap" so to speak. Then you can always clear your display inventory texts or whatever and re-assign them to whatever's in your listbox.

Probably not the most efficient way of doing it, but it works!

 
--

"Del Duio has received 0 trophies. Click here to see them all."

"To be a true ninja you must first pick the most stealthy of our assorted combat suits. Might I suggest the bright neon orange?"

DXF Games, coming next: Hasslevania 2- This Space for Rent!

UrbanMonk

BRING BACK MITCH

Registered
  07/07/2008
Points
  49566

Has Donated, Thank You!Little Pirate!ARGH SignKliktober Special Award TagPicture Me This Round 33 Winner!The Outlaw!VIP MemberHasslevania 2!I am an April FoolKitty
Picture Me This Round 32 Winner!Picture Me This Round 42 Winner!Picture Me This Round 44 Winner!Picture Me This Round 53 Winner!
23rd February, 2011 at 21:50:29 -

It ended up being more complicated than I thought.

But it works.

It records what objects have been picked up already (as long as you don't have duplicates) and what objects are in the inventory.

You can also have multiple save's in one file by changing the username that's stored in a global string.

http://jfile.us/713541d

 
n/a

vetmora120



Registered
  07/01/2010
Points
  273
24th February, 2011 at 02:19:59 -

Ah, excellent! Thank you very much for all your help.

I was going to ask you about the multiple saves thing as well but thought you already had enough on your plate So thank you for your initiative.

 
n/a
   

Post Reply



 



Advertisement

Worth A Click