User Tag List

Page 2 of 2 FirstFirst 1 2
Results 11 to 16 of 16

Thread: Need help with Arrays (Basic question I guess ^^)

  1. #11
    Clicker Multimedia Fusion 2XNA Export Module
    Gogeta's Avatar
    Join Date
    Aug 2012
    Location
    Germany
    Posts
    24
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hello Marv, you mean this one? http://www.castles-of-britain.com/mm...ual-arrays.htm ?
    I tried to understand it and too be honest, I did an epic fail... *lol*

  2. #12
    Clicker Fusion 2.5
    Del_Duio's Avatar
    Join Date
    Sep 2008
    Location
    Cygnus X-I
    Posts
    944
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Gogeta View Post
    So basically I could make an Array with just x and write to X_Array1 = Knife and make a loop that takes all itemclasses (made with groupinventar or something like this) and put it in X_Array + 1 so I dont need to write ever item manualy?

    To writing one simple Value I dont need a array. How about writing dozens of stuff? I think loop is the only way, right?
    Well you know, for the past couple games I've made I've figured out that actually the List object is fantastic for inventories. It's nice because picking an item up is easy (ListObj -> Add Line "Short Sword") and dropping an item (or equipping it) is just as easy (ListObj -> Delete line(ListIndex(YourSelection))). I use them for data storage only so they're always off screen / frame and not visible to the player.

    I've been using list objects for random treasures and holy **** is it ever easier! Honestly this might be the best way I've ever found with MMF2 (IMO of course!)

    Here, check this out: Let's say for your game every time the hero opens a chest up there's a 90% chance of getting a regular treasure and a 10% chance of getting something really awesome. What you can do is create 2 list objects that contain all the possible chest rewards- one that holds the regular stuff and one that holds the 'good' stuff. You're going to be taking something from one of those 2 lists and adding it to your hero's own list of gear called LstYOURITEMS.

    List boxes are cool because you can add the data at runtime or beforehand (great for testing purposes!)

    LstREGULARSTUFF
    "Short Sword"
    "Health Potion"
    "Wooden Club"

    LstGOODSTUFF
    "Magic Sword"
    "Super Axe"
    "Bazooka +20"

    Then when you have your events to open a chest-

    Upon pressing "SPACE BAR"
    + Guy is over a treasure chest object
    + Random # 1-100 is <=90
    -> Add Line to LstYOURITEMS(LstREGULARSTUFF(Random(# of Lines of LstREGULARSTUFF)+1))

    Upon pressing "SPACE BAR"
    + Guy is over a treasure chest object
    + Random # 1-100 is > 90
    -> Add Line to LstYOURITEMS(LstGOODSTUFF(Random(# of Lines of LstGOODSTUFF)+1))


    Using this method, you can further tweak your loot drops to better suit your game. Let's say that out of all the regular stuff you want mostly heal potions. Edit your LstREGULARSTUFF so it now looks like this:

    LstREGULARSTUFF
    "Short Sword"
    "Health Potion"
    "Wooden Club"
    "Health Potion"
    "Health Potion"

    Now you'll randomly get health potions 50% of the time, 90% of the time.

    Hahaha, sorry I hope this makes sense. Anyways, like my old computer teacher told me back in 7th grade (in the 80s!), I may not do things the "right way" but they usually work out okay in the end.

  3. #13
    Clicker Multimedia Fusion 2XNA Export Module
    Gogeta's Avatar
    Join Date
    Aug 2012
    Location
    Germany
    Posts
    24
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This make perfect sense for Inventory! Thank you!
    But how do you display them in a custom made inventory graphics? Is there a good way to sort them automatically, when you get new stuff, in like a 6 by 6 grid? I really thought that making 36 "If... then..." is a bit stress and that arrays are the only way around it. xD

  4. #14
    Clicker Fusion 2.5
    Del_Duio's Avatar
    Join Date
    Sep 2008
    Location
    Cygnus X-I
    Posts
    944
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Gogeta View Post
    This make perfect sense for Inventory! Thank you!
    But how do you display them in a custom made inventory graphics? Is there a good way to sort them automatically, when you get new stuff, in like a 6 by 6 grid? I really thought that making 36 "If... then..." is a bit stress and that arrays are the only way around it. xD
    That might be the complicated part, in that case you could use the list box objects to add / delete your overall player stock and then you'd have to assign all that to an array (or maybe global values).

    I think what you could do is this:

    Create 36 clones of the active objects "INV_GRIDITEMS" and line them up 6 x 6 like you describe above. At the start of the frame, spread value 0 in one of their alt values, and an Alt string called "ITEMNAME$". Give them all the collectible qualifier (this is what I'm currently doing for my game's inventory by the way).

    Then you have a line like this:

    Always ->
    Set "ITEMNAME$" of INV_GRIDITEMS 1 to LstYOURITEMS(1)
    Set "ITEMNAME$" of INV_GRIDITEMS 2 to LstYOURITEMS(2)
    Set "ITEMNAME$" of INV_GRIDITEMS 3 to LstYOURITEMS(3)
    etc...

    Yes, all 36 times. I realize this is a big pain in the ass and although I've tried many times using loops and junk they never work correctly so writing it all out that one time is worth it to me to have a working game

    Then after that part, you have lines like this:

    Always ->
    + Alt String "A" of Group.Collectible = "" then set direction of Group.Collectible to 0

    Always ->
    + Alt String "A" of Group.Collectible = "Short Sword" then set direction of Group.Collectible to 1

    Always ->
    + Alt String "A" of Group.Collectible = "Health Potion" then set direction of Group.Collectible to 2

    Always ->
    + Alt String "A" of Group.Collectible = "Wooden Club" then set direction of Group.Collectible to 3

    And etc, for every type of item you're going to have in your game. This only assumes your active object "INV_GRIDITEMS" is using one animation with 32 directions (one for each item picture and 0 being the "blank" grid), but very easily you could have one animation for weapons w/ 32 directions, one for armor w/ 32 directions and etc. Currently, my game is using 4 animations w/ 32 directions apiece.

    So all of this will constantly update your inventory icons in the grid with the string values in your off-screen list object "YOURITEMS" and change the grid pictures accordingly. If you were to have the guy drop an item and delete a spot in your list, it'd automatically shuffle your items around for you because that's one of the inherent features of a list object anyway (also why they are so cool for this sort of stuff.)

    I hope this helps you, it really does work I swear!

  5. #15
    Clicker Multimedia Fusion 2XNA Export Module
    Gogeta's Avatar
    Join Date
    Aug 2012
    Location
    Germany
    Posts
    24
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well I got it...now I know how to handle the listobject and that make perfect sense for an inventory menu. Thanks fior that, I'll try it out later.
    But the old problems is stil consistent: I dont get the array objects. xD

    Can you post a simple example how to use it for stuff except inventory (like RPG Stats, Quests etc...)?

    Thanks again, you helped me out a lot (if I can use it but this makes total sense ^^)!

  6. #16
    Clicker Fusion 2.5
    Del_Duio's Avatar
    Join Date
    Sep 2008
    Location
    Cygnus X-I
    Posts
    944
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Marv's example is better than what I could tell you about inventory arrays to be honest.

    I'm glad I could help you out, sorry we got so derailed but hey that happens.

    When you get something going, you should post info about your game up on the Clickteam blog

Page 2 of 2 FirstFirst 1 2

Similar Threads

  1. Basic randomizing question
    By Macaw in forum Multimedia Fusion 2 - Technical Support
    Replies: 6
    Last Post: 15th August 2013, 12:40 PM
  2. Question about Arrays
    By Bipolar_Games in forum Multimedia Fusion 2 - Technical Support
    Replies: 9
    Last Post: 23rd October 2011, 08:10 PM
  3. Basic question about HWA
    By teddyq in forum Hardware Accelerated Runtime
    Replies: 6
    Last Post: 1st March 2008, 06:38 PM
  4. Basic Question - Vista compatible
    By txventure in forum The Games Factory 2 - Technical Support
    Replies: 2
    Last Post: 23rd December 2007, 03:40 PM
  5. Very basic Moogame/Mooclick question
    By Taofeld in forum Multimedia Fusion 2 - Technical Support
    Replies: 5
    Last Post: 26th September 2007, 11:56 PM

Posting Permissions

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