Arrays
Photics
Member Posts: 4,172
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.)
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
idk what your'e asking
What would be best would be to have a function that allows coding like on GameMaker.
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.
I can't think of an example at the moment ;_; But I'll come back the second I do C:
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.
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.
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.
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
Send and Receive Data using your own Server Tutorial! | Vote for A Long Way Home on Steam Greenlight! | Ten Years Left
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
Thanks again MH.