Arrays

PhoticsPhotics Member Posts: 4,172
edited November -1 in Working with GS (Mac)
I used to be part of a web development team in NYC. I was the guy in the middle. The marketing department wanted new features to be implemented by the Information Technology department. But before that could happen, I needed to write down technical requirements. While creating the requirements, I had to find common ground. How could the limited resources of IT meet the huge demands of Marketing? With creating thinking, and a solid understanding of both sides of the issue, I was often able to create solutions that met the requirements of Marketing, while mitigating the work involved by the IT department.

What does that have to do with Arrays?

I see a lot of requests for Arrays around here. Yet, it seems like it would be a tough fit inside of GameSalad. How would it work? How would you build a simple behavior to make arrays happen? If we can present an easy way to implement this feature, then it could move it along.

I think this thread is a good way to educate the community about basic programming concepts and how they apply to games, while moving GameSalad forward.

How would an "Array" behavior look and function?
(Screenshots / Illustrations are a good idea.)

Comments

  • ToastKittenToastKitten Member Posts: 360
    instead of a new attribute like boolean, integer, real... Just add a '+' button for an array of that data type which can be set to any length?

    idk what your'e asking :/

    What would be best would be to have a function that allows coding like on GameMaker.
  • PhoticsPhotics Member Posts: 4,172
    ToastKitten said:
    instead of a new attribute like boolean, integer, real... Just add a '+' button for an array of that data type which can be set to any length

    What's the example? How would actors react to that data?
  • ToastKittenToastKitten Member Posts: 360
    idk what's an example of something that'd need arrays?
  • PhoticsPhotics Member Posts: 4,172
    ToastKitten said:
    idk what's an example of something that'd need arrays?

    I don't know. That's why I created this thread. Ha ha. If the community can't articulate this message, then it's easier for the GameSalad team to ignore it. If arrays are really so important to GameSalad game developers, then it should be easier to list specifics.

    I think it's useful when you're creating the background for an RPG. You can use lots of little graphics to make up the scene, reusing many graphics to save memory. I'm not sure why that would be better than simply placing actors on the screen.
  • ToastKittenToastKitten Member Posts: 360
    idk, let's say you want 1,000 different values for 1 array.... then, when you want different values pulled from that array, you don't have to go and create an attribute for every single numerical attribute you'd want. You'd still have to create a method for filling the arrays *like a for loop within GS* but it's a lot easier to just create 1 array of a data type instead of 1,000 different arrays.

    I can't think of an example at the moment ;_; But I'll come back the second I do C:
  • SnowSnow Member Posts: 124
    Arrays in GS would be good for storing different behaviors that you might want to cycle through. If you need actor x to reset a scene only when touching the floor in scene 1,3, and 7 out of 10, for example. Instead of having to individually edit behaviors in each scene, you might be able to do that on a global level and so whenever you want the actor to change certain behaviors - just call it up in the array. This way you could have dynamic actors that change per scene.

    Arrays are also good for if you want to apply a certain behavior to a batch of actors. You can always create more parents and have a certain parent for a certain behavior. But suppose you have 60 strategically placed instances that all turn yellow when touched by the main actor... but now you want 30 of those instances to turn blue. With an array, you could call 30 of them - turn their changing color from yellow to blue.

    Arrays also have a lot of functions themselves. You can splice them up, add/subtract objects form them, reorder them, etc, etc. There's a lot of clever little things you could do with them.
  • EastboundEastbound Member, BASIC Posts: 1,074
    Okay, an easy example to use for demonstration purposes could be a star system for performance of levels, as in Angry Birds and many many other iPhone games.

    I want to use an array so that I can use one array to store the score of each level (1-3) in one array instead of an integer that has to be saved and loaded for every level.

    So, I could just change score[20] = 3 to change the medal of level 20 to be a gold one.

    **I hope I explained this enough, now for how I would like GS to implement them**

    I see array being just another variable type that you create, and when you select an array variable in Change Attribute or Constrain Attribute behaviors, an 'index' box appears (with the same options of the equation editor). This way, one can change the indexes on the fly, and even use variables and such to fill the arrays. This would restrict the use Arrays inside of Arrays, however.
  • LordTarantorLordTarantor Member, PRO Posts: 890
    I totally agree, this post is a must. Also for the understanding of what are the arrays. If GS is really going to listen to what we say or ask for, i think it would be very important for all the people to understand what arrays are so if the think they need them, then they are going to ask for it.
    I have asked a couple of questions about how to do this or how to do that and I have received the answer that it can only be made with arrays and at the moment GS don't have those. So I don't know what an array is but I need them.
  • LordTarantorLordTarantor Member, PRO Posts: 890
    Thank you Eastbound... Can somebody traduce me that to Stupid so I can have an idea?
  • MotherHooseMotherHoose Member Posts: 2,456
    Right @Eastbound!

    An Index type variable is the closest thing we have to an array...
    I use it them all the time!

    For a long list of variables in the Index...make a note an list them there
    0= whatever
    1= something else
    and so on and on.

    then you just make your rules
    when an event occurs then the Index is #
    ..when game.*Index is #
    ..this happens

    Index are great for loading images during runtime...

    MH
  • LordTarantorLordTarantor Member, PRO Posts: 890
    Hi MotherHoose. Thanks for saying that you use index attribute because I have never used them, I don't even know what you can do with them... Since you use them a lot, can you explain them to me, please may be a couple of examples. I will really appreciate it.
  • jonmulcahyjonmulcahy Member, Sous Chef Posts: 10,408
    arrays would be killer in my new game. It's going to have 150 levels in which I need to track if it's been completed, how many items collected and the score. I could be using just 3 arrays, but if I make it with GS I'm going to need 450 attributes alone.
  • MotherHooseMotherHoose Member Posts: 2,456
    @LordTarantor

    to do a comprehensive guide to what an Index is/does would require a tutorial.

    As you know an Index is a quick way of referencing/locating something...the Index in a textbook tells you what page a subject is on.

    Your computer screen is Indexed; each pixel has an assigned X and Y coordinate. In graphics...the reference Index is for colors at that/those X and Y points.

    Tables and Arrays use columns and rows as Indexed reference points...Forms use fields for their Index. and a Database uses a Form type of storage...All are accessed by an Index # or name....Our Index-type variable is sorta a simple single column numerical table or array.

    You could use an integer instead of an index... but although both have a numerical value they are accessed and manipulated by the computer in slightly different methods. Integers are rational or irrational numbers...they can be positive or negative. An Index number is always a whole and a positive number. We are dealing in nanoseconds but IMO the methods the computer uses affect the FPS.

    ===
    EX: if you were making a hundred-question quiz... an Index would be good!
    create an Index variable named qxIndex
    create an Integer variable named numberPick (you need this because you can change an Index variable but you can NOT manipulate it.)

    create your control actor/button
    make a note listing from 1 to 100 with each question/answer assigned to a number
    [Rule]
    event ... touch is pressed
    ChangeAttribute game.numberPick ...To: random(1,100)
    ChangeAttribute game.qxIndex... To: game.numberPick
    [Rule]
    game.qxIndex = #
    DisplayText or Image that is assigned to that number

    you can create more variables as integers to reference question(s) completed...and have a rule that when numberPick = question # then do the random pick again.

    ===
    I always make an Index variable for scenes
    and have the actors off screen
    then on each actor if I want them in that scene:
    [Rule] when sceneIndex = 2
    Change Attribute actor.X to whatever
    ChangeAttribute actor.Y to whatever

    or I might just have a blank frame and change the Image to whatever for each scene...that works good for changing button images rather than making new button actors.

    hope this helped.

    If you email me at gmail I will send you a program where I used an Index and you can see how efficiently it works. (too big to upload...)

    MH
  • LordTarantorLordTarantor Member, PRO Posts: 890
    Wow MH thanks for the explanation this one should go in the wiki. I got the idea now. I sent you the email so you can send me the program to see it in action.
    Thanks again MH.
Sign In or Register to comment.