A Flash Developer Resource Site

Results 1 to 17 of 17

Thread: Creating an inventory?

  1. #1
    Senior Member
    Join Date
    Nov 2000
    Posts
    195
    Hi

    We have a game called Enchantment and we need an inventory system. How would we go about this? The reason we need it is that there will be shops around our world that sell simple items (sword, shield, potion, map etc).

    I have heard that a good method of doing this would be to have movie clips for each item (there will be about 10 items to start with) that have a first frame that is blank. Then when you go into a shop and purchase an item it deducts the money and then tells the inventory something like this...

    on(buy) gotoAndStop(_root.inventory.sword 2)

    Then when you go to your inventory it shows that you now have it.

    There are several problems with this I think though.

    What i really would like is if someone has made an inventory before or knows how to do one, if they could post instructions on this thread. Its a complex subject I guess!

    For a quick taster of the 3D game engine so far :-
    http://ceti.macam.ac.il/sebs/iso9.swf

    If you wish to help us and require the .fla please email me
    dan@funfrock.net

    Thanks in anticipation of your help!
    Dr_Funfrock

  2. #2
    Senior Member Mad-Sci's Avatar
    Join Date
    Mar 2000
    Posts
    2,756
    I would rather use an array system to hold whatever the player buys like:

    Items=new Array();

    for ( i=1;i<=max_tems;i++){
    items['i]=""; // init the array at the begging we have nothing

    }

    Items could be monney or potions, but if you have design like in Diablo ( belt or stash ) you need 2 array systems.

    when ever you want to display what we have like pressing a key for example. just look in the array to see what Items we have. When you want to pick an item just modify the array.

    when hitTest with item();

    for (i=1;i<=max_items,i++){

    if ( item['i] eq ""){ item[`i]=Picked_item;picked_item="";break;}
    }
    if ( picked_item ne ""}{msg="You cant pick it up";}


    }

    so
    [Edited by Mad-Sci on 06-07-2001 at 02:41 PM]

  3. #3
    Senior Member
    Join Date
    Apr 2001
    Posts
    190
    Might as well just add:

    Code:
    if (picked_item ne "") {
      msg = "You cant pick it up";
    } else {
      msg = "You picked up "+item['i];
    }
    [Edited by Somar on 06-07-2001 at 05:54 PM]

  4. #4
    Senior Member
    Join Date
    Nov 2000
    Posts
    195
    Hmmmmm in principle that sounds better BUT (yes there is always a but my friends!) I have no idea on how to add something like that. Is there any chance you could create a .fla documenting the basics of this for me to have a look at and see how it's done. Then I can think about adding it to my game.

    These are the basics of what I would like to add.

    1) Money - consisting of gold pieces
    2) Potion to revive your health
    3) Sword, you are given this at the start
    4) Shield, to protect a bit against enemies
    5) Map, of the world.
    6) Bombs, to blast enemies
    7) Acannian Orb, the aim of the game is to get this.

    Cheers for helping......me hopes!
    Dr_Funfrock.

  5. #5
    Senior Member
    Join Date
    May 2001
    Posts
    425
    i would also like to see how you would make an invantory array. also, would there be a way to make a graphical interface with this, and make an engine that would search for an empty space in your inventory to put things in?
    I'm confusing you i know.

    Well i was trying to make like a grid with a set ammount of space bricks. then each item would have a size in bricks. then an engine would search your space(or always know),for an empty place and if there was one, then the item would be placed there, else, it would be ignored(or dropped).

    i haven't an idea where to start with this.

  6. #6
    Senior Member
    Join Date
    Nov 2000
    Posts
    195
    It would seem like we have stumbled upon a very complex situation but one that if created, would give our games a totally new dimension.

    Lets hope we can get somewhere with this thread!

    Thanks to everyone who has /who is thinking of posting.

    Dr_Funfrock.

  7. #7
    Dr FunFrock, i am working on an inventory for my game. I have it working so far (the graphical part). If you want to check it out, look at my game:

    http://www21.brinkster.com/sli/link.html

    Please ingore the graphics and everything as the game is in EXTREAM beta. But if you want to see it, there it is :P To pick up one of the red bottles, stand over it and hit the \ key. The white sliver on the left side of the screen opens the (cheesy and temporary) inventory panel. You can see the bottles in there. You cant use the bottles yet, but ill have that working soon.

    Oh and ignore the dumb guy chasing you, he doesnt do anything yet, just runs after you :P

    Enjoy

    Elyxia Elvinbright

  8. #8
    Senior Member
    Join Date
    Sep 2000
    Posts
    467
    hey ElyxiaElvenbright,

    could you please give us the fla or email it to letser@hotmail.com

    tnx, ^1letser

  9. #9
    Senior Member
    Join Date
    Nov 2000
    Posts
    195
    Geez that is just perfect! If you could send me the .fla I will of course be delighted to feature you in the credits for inventory engine design, and include a url for a website of your choice.

    I hope you will as that is excelent world my friend!

    Good luck with your game too,
    Kind regards,
    Dr_Funfrock

  10. #10
    Glad you like it Here is the link for the fla. I removed some elements that dont pertain to the inventory, since i dont like to give away everything ive worked on (sorry, im not stingy, just.... pertective?) but anywho, hope this helps!!!

    Remember, this is not fully functional yet, ill hopfuly have it so you can USE the items once oy uget them into your INV during my lunch today

    here is the link: http://www21.brinkster.com/sli/LinkInv.fla

    Talk to you soon.

    Elyxia Elvinbright
    [Edited by ElyxiaElvenbright on 06-08-2001 at 03:14 PM]

  11. #11
    Senior Member
    Join Date
    Nov 2000
    Posts
    195
    no link. are you posting after the items can be used? me hopes so as that sounds like the real deal!

  12. #12
    Senior Member
    Join Date
    Nov 2000
    Posts
    195
    sorry i see the link, i am blind

  13. #13
    Ok, link is in there now, forgot it the first time :P And no, sorry, havnt had my lunch yet so the fla is just like the "game" you demoed this morning :P

    Elyxia


  14. #14
    Senior Member
    Join Date
    Nov 2000
    Posts
    195
    i knew there want one at the start!!!! hehehe

  15. #15
    Senior Member
    Join Date
    Sep 2000
    Posts
    467
    tnx for the fla ElyxiaElvenbright and I don't your beeing stingy. I would do the same myself

    tnx

  16. #16
    Senior Member
    Join Date
    Jun 2000
    Posts
    435
    Humm?

    An advanced menu / inventory for RPG’s sounds like a fun challenge to under take!

    I will put some thought in to it over the weekend; I will let you know what I come up with on Monday!

  17. #17
    Senior Member
    Join Date
    Jul 2000
    Posts
    198
    Hey guys. Here is my idea for an inventory:
    Say you have 10 places for the inventory, and 10 different items. In one movie clip, you have all the items on a seperate frame, with a stop action in the beginning.

    heres some code (psuedo code, youll have to try it, i dont know if it works )

    in the item:
    on (enterframe) {
    if (this.hittest(_root.hero)) {
    _root.pickedup = true;
    _root.whatpicked = 1; //or the number corresponding to this item
    }
    }

    in the hero:
    on(enterframe) {
    if(_root.pickedup) {
    for(item=0, item<10, item++) {
    if (_root.item[item] == 0) {
    _root.item[item] == _root.whatpicked; //update the array
    _root.inventory[item].gotoandstop(item); //update the display
    break;
    }
    }
    }
    }

    I hope you can understand that. If you need to check for an item, just have a loop to check the array for the corresponding number.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center