View unanswered posts | View active topics It is currently Thu Oct 23, 2014 11:23 am






Reply to topic  [ 2 posts ] 
Arrays 
Author Message
Novice

Joined: Sun Oct 21, 2012 10:01 pm
Posts: 76
Post 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 piece
const 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
   }
};


Wed Oct 24, 2012 10:17 pm
Profile
Site Admin
Site Admin

Joined: Wed Jan 24, 2007 10:42 am
Posts: 613
Post 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.

_________________
Timothy Friez
ROBOTC Developer - SW Engineer
tfriez@robotc.net


Thu Oct 25, 2012 9:37 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 2 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.