A few questions

Blitz3D Forums/Blitz3D Programming/A few questions

Zach3D(Posted 2006) [#1]
I have a few things i need help with

-Could i have an example of how to set up a shop, not necessarrily code, but a summarization of what i would do to make a shop in a 3D Rpg game.
-And could someone help me with how to make an inventory along with pickupitem and dropitem


octothorpe(Posted 2006) [#2]
In most games, a shop is represented by a graphic user interface (GUI.) The simplest approach is to define a bunch of clickable/selectable 2d "widgets" (like a windows program has buttons,) where each goes on the screen, and what each looks like. There are a number of Blitz3D GUI libraries out there that might help you with this, but they're fairly complicated - expect to spend some time learning one!

When your GUI code detects that the player has clicked on a "purchase" button, it calls a function in your shopkeeper code with an ItemID (and possibly a ShopID so your shops can charge different prices.) Your shopkeeper code then makes sure you have enough money, debits the amount, then adds a new item to your inventory.

Alternately, the GUI update routine could be called by your shopkeeping routine and its return value could yield what button (if any) was pressed.

If there's only one inventory in the game (i.e. one character,) you could exploit Blitz3D's builtin type lists to keep track of PlayerItems: create a "new" PlayerItem when the player picks up an item, "delete" PlayerItems as they are dropped. Listing the player's inventory would be as simple as a For..Each loop.

Managing multiple inventories and/or bags-within-bags means you'll need a more complex solution:

http://www.blitzbasic.com/codearcs/codearcs.php?code=1525
http://blitzbasic.com/Community/posts.php?topic=43141&hl=containers%20inventory