| Home | Tutorials | Forums | Articles | Blogs | Movies | Library | Employment | Press | Buy templates |
|
|
#1 |
|
..::juSt a gl!tcH;::.
|
Hi,
I would like to know if someone can explain 2 me or point me in the right direction, regarding multidimensional arrays. We are currently doing a research for a strategy game. Table in the game is 10x10 squares (each square 10x10px). Informations about the each square (owner, population, army, defence) are stored in md array, right? Example: field E 4,2 is Mike's land populated with 400 peps and has army of 240 niggaz and their def factor is 8. so basicaly if a player put more troops there i need to make calculations and write them back to array, or something like that. ..hope that you understand me...or i am dazzing of again.. ) |
|
|
|
|
|
#2 |
|
Risu Oyabun!
Join Date: Apr 2001
Location: Houston, Texas
Posts: 1,460
|
Arrays are like tables, as you already have discerned. Actionscripting handles arrays SO much better than VB, which I'm usually stuck using (feh). That being said, gaze below at this array:
gomph = ["narf", "snoogans", "chump"]; This is a single-element array. To return a value from the array you would simply reference the position you want, starting with an index of 0. Like this.... gomph[1] -==> "snoogans" Pretty basic, ja? Now check this action out... scoomag = [["narf", "miggle", "saskatchiwan"], ["humidor", "muckluck", "snootchy"]]; This is a multi-dimensional array. Basically, it's an array that contains an array. You can nest any number of arrays, it all depends on what you want out of it. With the above example, you'd reference it like this: scoomag[0] -==> ["narf", "miggle", "saskatchiwan"] scoomag[1][2] -==> "saskatchiwan" See? If you wanted to change a value in that array, you'd do something like dis: scoomag[1][2] = "gnafawil"; There are a myriad of functions fer the array. Things like splice and push are my favorite. They allow you to kill out elements in the array or add them in. Check out the help documentation for the array functions. You'll get a good idea on how to manipulate the data from there. Good luck, don't let no one bust a cap in yo' arse. |
|
|
|
|
|
|
|
|
#3 |
|
..::juSt a gl!tcH;::.
|
So, basicaly:
after that i use functions to calculate new data to store in arrays, using variables. If after this i am right..then i am geting somewhere... |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| testing two multidimensional arrays for equality | nathanleyton | ActionScript 1.0 (and below) | 2 | 08-27-2004 09:05 AM |
| MultiDimensional Arrays? | mekawi | ActionScript 2.0 | 1 | 12-30-2003 09:54 AM |
| Multidimensional arrays | summer | ActionScript 2.0 | 3 | 10-20-2003 07:22 AM |
| explain this code structure...i think its arrays *not sure* | boyzdynasty | ActionScript 1.0 (and below) | 5 | 04-20-2003 09:29 AM |
| looping through multidimensional arrays | devon | ActionScript 1.0 (and below) | 22 | 12-14-2002 09:47 PM |