PDA

View Full Version : Multi-Dimensional arrays?



Gleeok
03-29-2008, 07:59 PM
Can we do these? How do we access them?

For instance, something like:


int save_link_position[2][64];

if(Link->InputUp/down/left/right)
{
save_link_position[1][i]=Link->X;save_link_position[2][i]=Link->Y;i++;
}



And to read from arrays would you just reverse them?


if(i>15){
this->X = save_link_position[1][i-16];
}

Gleeok
06-13-2008, 12:10 AM
Just wondering if there is supposed to be two-dimensional arrays at this point, since there are a couple of bugs with them.

What I need to do is completely rewrite all of my custom enemies by type (to avoid foreseeable and unavoidable stack overflow) of level, movement, and difficulty setting.

The easiest thing to do would likely be:

enemy_type[ffc_num_enemy][enemy_specific_ffc_variables];

ffc script controller{ //stuff
{
for(i=1;i<init_num_variables;i++)
{
enemy_type[this_ffc_num][i] = (initialize_var[i]//local;
}
while(// etc..


void enemy1(int ffc, int level){
// do stuff
// then decrement the array accordingly



...is what i'm thinking. Or I could create lots separate arrays that do something similar....dear god...which is fine too. I think that Allegro itself has a limit to two dimensional arrays so not sure if we can use any or not.

If not, would anyone have any suggestions as to easily managing this.?

An array of arrays. :crazy:


EDIT: OK, I found an equally efficient alternative. Should be less of a burden on processer speed also..which brings me to my next question:

How do all those clowns fit into that tiny car?! :scared: :P

bigjoe
06-13-2008, 03:03 AM
When does stack overflow start to occur? I fear I might someday encounter it, as my scripts may get intensive.

Gleeok
06-13-2008, 04:50 AM
I dunno? Maybe around 70 kb of raw uncommented code...give or take.

jman2050
06-13-2008, 10:03 AM
The language grammar and implementation was designed with the possibility of multidimensional arrays IIRC. No one had attempted them up to this point, so I'd like for you to outline any issues you have at this point :P

Gleeok
06-13-2008, 09:50 PM
Ah, Well the only issue I'm getting with them currently, is that, well... they don't compile. XD

ScaryBinary
06-14-2008, 08:08 AM
Ah, Well the only issue I'm getting with them currently, is that, well... they don't compile. XD

I'll second that. I was declaring them as Gleeok did, something like:
int myArray[5][10]; I tried a few other non-standard declarations, but nothing seemed to work. This was with build...777, I believe.