View Full Version : Multiple Arrays
JapanMan
September 17th, 2008, 05:23 PM
I want to make a game in which you can shoot bullet objects at enemies that come in from the side, and try to attack you. I have the shooting handled by an array, and want to know how the best way to manage the enemies would be. I'm thinking of large numbers of simple enemies and having more than one on the screen at a time.
I figure this will be best handled with an array, so what things do I need to change in order to run the two arrays in the same script?
biznuge
September 17th, 2008, 05:30 PM
your best bet would be to stop right there, have a look at how classes work in OOD, and then progress from that point. If all your enemies are able to think for themselves in easily scaleable/editable code you'll be the most powerful super(cyber)villain on the block...
*ditch the multiple arrays man!* class it!
JapanMan
September 17th, 2008, 05:41 PM
im not saying they should think for themselves, but be created, and move to the other sude of the screen. I just want to use a createObject() function, and then say, if (they are close to the player) then they start attacking.
I dont need individual AI, just 2 arrays.
biznuge
September 17th, 2008, 05:51 PM
var myArr1:Array = new Array("1", "2", "3");
var myArr2:Array = new Array("4", "5", "6");
var myArr3:Array = new Array("7", "8", "9");
var myArray:Array = new Array(myArr1, myArr2, myArr3);
trace(myArray[0][1]);
Crazy thing is I'm sure I asked this question about 4-5 years ago in AS2 when I was trying to figure stuff out, and I'm pretty sure someone then told me to do it in a class (which I ignored) which gave me an insight into how an array works in flash....
Cool.... Brevity....:drool:
the dude abides...
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.