)
While doing the Pset4 task, i got this error in the initBricks function:
error: add: Unrecognized type GObject
This is the corresponding code:
...
#include "gobjects.h"
#include "gwindow.h"
...
// number of rows of bricks
#define ROWS 5
// number of columns of bricks
#define COLS 10
...
void initBricks(GWindow window)
{
const int brick_height = 10;
const int brick_width = 38;
GRect brick[COLS-1][ROWS-1];
for(int i=0;i<ROWS;i++){
for(int j=0;j<COLS;j++){
brick[j][i] = newGRect(j*(brick_width+2)+1, i*(brick_height+2)+1, brick_width, brick_height);
setColor(brick[j][i], "RED");
setFilled(brick[j][i], true);
add(window, brick[j][i]);
}
}
}
This draws two rows and in the third 9 bricks. Then the add-command throws the error. I have no idea what happened here. Maybe a memory/allocation problem? Has somebody any hints? Tanks in advance. Marcus