ROBOTC.net forumshttp://www.robotc.net/forums/ Arrayshttp://www.robotc.net/forums/viewtopic.php?f=1&t=5029 Page 1 of 1

Author:  amcerbu [ Wed Oct 24, 2012 10:17 pm ]
Post subject:  Arrays

I was working on a Tetris program for NXT, and had just created a multi-dimensional array for storing data about the pieces. The compiler told me...

**Error**:Too many array indices. Max allowed is '2'.

Does that mean that only 2-dimensional and smaller arrays are allowed in RobotC? What about an array of structs, where each struct contains an array?

Anyway, here's the code. PIECES, ROTATIONS, and BLOCKS are all #defined at the beginning of the .c file.
 Code:// measures the offsets, in squares, from the center square for each orientation of each piececonst short xyOffsets[PIECES][ROTATIONS][BLOCKS - 1][2] ={   // O block   {      {{-1, 0}, {-1, -1}, {0, -1}}, // orientation 0 {x, y}      {{-1, 0}, {-1, -1}, {0, -1}}, // orientation 1      {{-1, 0}, {-1, -1}, {0, -1}}, // orientation 2      {{-1, 0}, {-1, -1}, {0, -1}}  // orientation 3   },   // I block   {      {{-2, 0}, {-1, 0}, {1, 0}},   // orientation 0      {{0, 1}, {0, -1}, {0, -2}},   // orientation 1      {{-2, 0}, {-1, 0}, {1, 0}},   // orientation 2      {{0, 1}, {0, -1}, {0, -2}}    // orientation 3   },   // S block   {      {{-1, -1}, {0, -1}, {1, 0}},  // orientation 0      {{0, 1}, {1, 0}, {1, -1}},    // orientation 1      {{-1, -1}, {0, -1}, {1, 0}},  // orientation 2      {{0, 1}, {1, 0}, {1, -1}}     // orientation 3   },   // Z block   {      {{-1, 0}, {0, -1}, {1, -1}},  // orientation 0      {{0, -1}, {1, 0}, {1, 1}},    // orientation 1      {{-1, 0}, {0, -1}, {1, -1}},  // orientation 2      {{0, -1}, {1, 0}, {1, 1}}     // orientation 3   },   // L block   {      {{-1, -1}, {-1, 0}, {1, 0}},  // orientation 0      {{0, 1}, {0, -1}, {1, -1}},   // orientation 1      {{-1, 0}, {1, 0}, {1, 1}},    // orientation 2      {{-1, 1}, {0, 1}, {0, -1}}    // orientation 3   },   // J block   {      {{-1, 0}, {1, 0}, {1, -1}},   // orientation 0      {{0, -1}, {0, 1}, {1, 1}},    // orientation 1      {{-1, 1}, {-1, 0}, {1, 0}},   // orientation 2      {{-1, -1}, {0, -1}, {0, 1}}   // orientation 3   },   // T block   {      {{-1, 0}, {0, -1}, {1, 0}},   // orientation 0      {{0, -1}, {1, 0}, {0, 1}},    // orientation 1      {{-1, 0}, {0, 1}, {1, 0}},    // orientation 2      {{0, 1}, {-1, 0}, {0, -1}}    // orientation 3   }};

 Author: tfriez [ Thu Oct 25, 2012 9:37 am ] Post subject: Re: Arrays Yes - Only two dimensional arrays are supported in ROBOTC. There are no plans to increase this limitation at the moment.You can have structs and arrays of structs, however. The support for structs has been greatly increased with ROBOTC 3.5 and above.

 Page 1 of 1 All times are UTC - 5 hours [ DST ] Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Grouphttp://www.phpbb.com/