Home Tutorials Forums Articles Blogs Movies Library Employment Press Buy templates

Go Back   ActionScript.org Forums > General > Gaming and Game Development

Reply
 
Thread Tools Rate Thread Display Modes
Old 07-25-2001, 03:52 PM   #1
RealBBoy
..::juSt a gl!tcH;::.
 
RealBBoy's Avatar
 
Join Date: Jun 2001
Location: Belgrade, Jamaica..oh sorrey, Yugoslavia
Posts: 80
Send a message via ICQ to RealBBoy Send a message via AIM to RealBBoy Send a message via Yahoo to RealBBoy
Question

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..)

RealBBoy is offline   Reply With Quote
Old 07-25-2001, 06:42 PM   #2
20 Ton Squirrel
Risu Oyabun!
 
20 Ton Squirrel's Avatar
 
Join Date: Apr 2001
Location: Houston, Texas
Posts: 1,460
Default

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.




20 Ton Squirrel is offline   Reply With Quote
Old 07-25-2001, 06:48 PM   #3
RealBBoy
..::juSt a gl!tcH;::.
 
RealBBoy's Avatar
 
Join Date: Jun 2001
Location: Belgrade, Jamaica..oh sorrey, Yugoslavia
Posts: 80
Send a message via ICQ to RealBBoy Send a message via AIM to RealBBoy Send a message via Yahoo to RealBBoy
Thumbs up

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...
RealBBoy is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

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


All times are GMT. The time now is 01:03 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2009 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.