I've been staring at the following code for a little while now, and I can't for the life of me figure out why it fails. The array stuff is very touchy, but I've used arrays this exact same way many times. If you put this code in it's own "system.vc" file and try to compile it, it stops on the line:
choice_y[0] = 25;
...complaining that it was looking for a "," but got a "[". Err... what the heck am I missing?
void show_combat_menu()
{
int num_of_options,selection;
num_of_options = 2; // to be determined by available options...
selection = 0;
int choice_y[num_of_options];
choice_y[0] = 25;
choice_y[1] = 40; // should be done with for loop
rectfill(220,0,320,30,rgb(0,0,0),screen);
PrintString(250,choice_y[0],screen,fnt,"Move");
PrintString(250,choice_y[1],screen,fnt,"Pass");
CircleFill(240,choice_y[selection],2,2,rgb(255,0,0),screen);
ShowPage();
while (!key[SCAN_ENTER])
{
UpdateControls();
if (key[SCAN_UP])
{
selection--;
if (selection num_of_options - 1)
{
selection = 0;
}
}
rectfill(230,0,320,30,rgb(0,0,0),screen);
PrintString(250,choice_y[0],screen,fnt,"Move");
PrintString(250,choice_y[1],screen,fnt,"Pass");
CircleFill(240,choice_y[selection],2,2,rgb(255,0,0),screen);
ShowPage();
}
if (selection == 0)
{
grid_move();
}
// else if ... etc...
}
Am I stepping on a key word?
Did I miss something in there?
My code works fine without this function, so it's just this code.
Thanks!
-l