Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / How do you do an inventory?

Author
Message
Red general
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: United Kingdom
Posted: 4th Jan 2003 21:34
How do you do an inventory where yuo can click on sprites in the game to put them in the inventory, and click on the sprites in the inventory to use them on other sprites in the game? - red general
John H
Retired Moderator
21
Years of Service
User Offline
Joined: 14th Oct 2002
Location: Burlington, VT
Posted: 5th Jan 2003 03:45
I thought I posted about this earlier------------------- Well anways. Not easy. I would suggest storying sprite data in an array and if the mouse is clicked on a certain sprite then call the data. The kind of inventory you are talking about is very complicated, im just using text so I can read it with a couple commands very easily

RPGamer

Current - RPG: Eternal Destiny : Help Wanted!
http://www.halbrosproductions.netfirms.com
Dont ask those questions! Read the help files lazy!
Dr DooMer
21
Years of Service
User Offline
Joined: 22nd Dec 2002
Location: United Kingdom
Posted: 5th Jan 2003 03:59
Yeah - there's so many ways of doing it, but none of them are particularly easy to implement.

Really, this is one you should figure out yourself; I don't know, I've never done it myself, but it sounds like a good system to code just for learning purposes.

Elaborating on what RPGamer said, arrays are certainly the way to go - you'ld need an array of size equal to the maximum storage space in your inventory (assuming each item takes up the same amount of space) and, as the user collects items, find a free spot in the inventory array and fill it with a number that corresponds to that particular item. Your visual display would then look through this array and pick out what item is in each inventory slot, displaying an appropriate sprite somewhere on the screen.

As for using inventory, you would let the user select the item in some manner, and then designate the slot that the item is in as the 'active slot' or something. When the user then uses the item on some other object, your program would check what the object in question is, what slot is currently the active slot and what item is in it, and whether the item and object can be used together. After that, you would probably want to set the active slot to a null value or something (-1 is usually a good idea), to effectively deselect the inventory item.

Sorry to be long winded, but this should hopefully give you the insight needed to solve your problem. If not, I'm just a fool.

"I am a living, thinking entity who was created in the sea of information."
Red general
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: United Kingdom
Posted: 6th Jan 2003 22:15
I'm having problems with do the arrays - I don't under stand how to save something to an array and then take the information from it

Dr DooMer
21
Years of Service
User Offline
Joined: 22nd Dec 2002
Location: United Kingdom
Posted: 6th Jan 2003 23:49
This line:

dim my_array(5)

Will create an array that can effectively be considered as 6 individual variables:

my_array(0),
my_array(1),
my_array(2),
etc.

Entering the command "my_array(2) = 5" will set that part of the array to 5. You can then retrieve this value by entering a line like:

print my_array(2)

This will cause DB to print the number 5.

Perhaps I'm getting ahead of myself, but not knowing how to use arrays suggests that you haven't followed the tutorials...

"I am a living, thinking entity who was created in the sea of information."
John H
Retired Moderator
21
Years of Service
User Offline
Joined: 14th Oct 2002
Location: Burlington, VT
Posted: 7th Jan 2003 03:07
Dont even say the word Inventory without knowing how to use arrays You need to store all the data in arrays, and when you fill a slot then slot1=1 etc and do that until like slot 50=1 if all the slots =1 then you cant put in items.

Then if you have to load the data you need to go into the inventory array, find the space being used, and grab the data from THAT array. Ahh, if only I could use types

Item systems are complicated Master Arrays first

RPGamer

Current - RPG: Eternal Destiny : Help Wanted!
http://www.halbrosproductions.netfirms.com
Dont ask those questions! Read the help files lazy!

Login to post a reply

Server time is: 2024-04-25 05:52:33
Your offset time is: 2024-04-25 05:52:33