M
Mark
uhhmmm... not really sure how to word this.
i cant get get this to compile.. i'm not sure what the proper syntax to
do this is.. hopefully it's self explanatory.
here's my class:
------
class TileMap
{
public:
int xw, yw;
int tw, th;
int rows, cols;
int fullrows, fullcols;
int minX, minY, maxX, maxY;
TileMapCell **grid;
TileMap(int rows, int cols, int xw, int yw) : rows(rows),
cols(cols), xw(xw), yw(yw)
{
tw = xw*2;
th = yw*2;
fullrows = rows+2;
fullcols = cols+2;
minX = tw;
minY = th;
maxX = tw + (rows*tw);
maxY = th + (rows*th);
}
TileMapCell GetTile_S(int x, int y)
{
return grid[int(x/tw)][int(y/th)];
}
TileMapCell GetTile_V(Vector2 v)
{
return grid[int(v.x/tw)][int(v.y/th)];
}
TileMapCell GetTile_I(int x, int y)
{
return grid[x][y];
}
void GetIndex_S(Vector2 v, int x, int y)
{
v.x = int(x/tw);
v.y = int(y/th);
}
void GetIndex_V(Vector2 v, Vector2 p)
{
v.x = int(p.x/tw);
v.y = int(p.y/th);
}
void Building()
{
int x = xw;
int y = yw;
int fullrows = fullrows;//the ACTUAL size of the grid, including
border tiles
int fullcols = fullcols;
int rows = rows;
int cols = cols;
//build raw tiles
for(int i = 0; i < fullrows; i++)
{
grid = new TileMapCell[fullcols]; // <--- need help here!!!
for(int j = 0; j < fullcols; j++)
{
grid[j] = new TileMapCell(i,j,x,y,xw,yw);
y += th;
}
x += tw;
y = yw;
}
}
};
--------------------
the problem is in here:
------------------
//build raw tiles
for(int i = 0; i < fullrows; i++)
{
grid = new TileMapCell[fullcols]; // <--- need help here!!!
for(int j = 0; j < fullcols; j++)
{
grid[j] = new TileMapCell(i,j,x,y,xw,yw);
y += th;
}
x += tw;
y = yw;
}
-----------------
and incase you were about to ask:
------------
class TileMapCell
{
public:
int ID;
int CTYPE;
int i,j; // index of tile in grid
TileMapCell *nU, *nD, *nL, *nR; // neighboring tiles
int eU, eD, eL, eR; // edge info
float gx; // environmental properties
float gy;
float d;
TileMapCell *next, *prev;
Vector2 pos;
int xw, yw;
float minx, maxx, miny, maxy;
int signx, signy, sx, sy;
TileMapCell(int i, int j, float x, float y, int xw, int yw) : i(i),
j(j), xw(xw), yw(yw)
{
pos.set(x,y);
gx = 0;
gy = GRAV;
d = DRAG;
nU = nD = nL = nR = NULL;
eU = eD = eL = eR = EID_OFF;
next = prev = NULL;
minx = pos.x - xw;
maxx = pos.x + xw;
miny = pos.y - yw;
maxy = pos.y + yw;
signx = signy = sx = sy = 0;
}
void LinkU(TileMapCell *t)
{
nU = t;
}
void LinkD(TileMapCell *t)
{
nD = t;
}
void LinkL(TileMapCell *t)
{
nL = t;
}
void LinkR(TileMapCell *t)
{
nR = t;
}
};
-------------------
and before you tell me
grid = new TileMapCell[fullcols];
doesnt work because there is no TileMapCell() constructor.... I know.
but it shouldnt really be constructing anything at that point... right?
if you need more info.. just leave a message.
thanks for the help.
i cant get get this to compile.. i'm not sure what the proper syntax to
do this is.. hopefully it's self explanatory.
here's my class:
------
class TileMap
{
public:
int xw, yw;
int tw, th;
int rows, cols;
int fullrows, fullcols;
int minX, minY, maxX, maxY;
TileMapCell **grid;
TileMap(int rows, int cols, int xw, int yw) : rows(rows),
cols(cols), xw(xw), yw(yw)
{
tw = xw*2;
th = yw*2;
fullrows = rows+2;
fullcols = cols+2;
minX = tw;
minY = th;
maxX = tw + (rows*tw);
maxY = th + (rows*th);
}
TileMapCell GetTile_S(int x, int y)
{
return grid[int(x/tw)][int(y/th)];
}
TileMapCell GetTile_V(Vector2 v)
{
return grid[int(v.x/tw)][int(v.y/th)];
}
TileMapCell GetTile_I(int x, int y)
{
return grid[x][y];
}
void GetIndex_S(Vector2 v, int x, int y)
{
v.x = int(x/tw);
v.y = int(y/th);
}
void GetIndex_V(Vector2 v, Vector2 p)
{
v.x = int(p.x/tw);
v.y = int(p.y/th);
}
void Building()
{
int x = xw;
int y = yw;
int fullrows = fullrows;//the ACTUAL size of the grid, including
border tiles
int fullcols = fullcols;
int rows = rows;
int cols = cols;
//build raw tiles
for(int i = 0; i < fullrows; i++)
{
grid = new TileMapCell[fullcols]; // <--- need help here!!!
for(int j = 0; j < fullcols; j++)
{
grid[j] = new TileMapCell(i,j,x,y,xw,yw);
y += th;
}
x += tw;
y = yw;
}
}
};
--------------------
the problem is in here:
------------------
//build raw tiles
for(int i = 0; i < fullrows; i++)
{
grid = new TileMapCell[fullcols]; // <--- need help here!!!
for(int j = 0; j < fullcols; j++)
{
grid[j] = new TileMapCell(i,j,x,y,xw,yw);
y += th;
}
x += tw;
y = yw;
}
-----------------
and incase you were about to ask:
------------
class TileMapCell
{
public:
int ID;
int CTYPE;
int i,j; // index of tile in grid
TileMapCell *nU, *nD, *nL, *nR; // neighboring tiles
int eU, eD, eL, eR; // edge info
float gx; // environmental properties
float gy;
float d;
TileMapCell *next, *prev;
Vector2 pos;
int xw, yw;
float minx, maxx, miny, maxy;
int signx, signy, sx, sy;
TileMapCell(int i, int j, float x, float y, int xw, int yw) : i(i),
j(j), xw(xw), yw(yw)
{
pos.set(x,y);
gx = 0;
gy = GRAV;
d = DRAG;
nU = nD = nL = nR = NULL;
eU = eD = eL = eR = EID_OFF;
next = prev = NULL;
minx = pos.x - xw;
maxx = pos.x + xw;
miny = pos.y - yw;
maxy = pos.y + yw;
signx = signy = sx = sy = 0;
}
void LinkU(TileMapCell *t)
{
nU = t;
}
void LinkD(TileMapCell *t)
{
nD = t;
}
void LinkL(TileMapCell *t)
{
nL = t;
}
void LinkR(TileMapCell *t)
{
nR = t;
}
};
-------------------
and before you tell me
grid = new TileMapCell[fullcols];
doesnt work because there is no TileMapCell() constructor.... I know.
but it shouldnt really be constructing anything at that point... right?
if you need more info.. just leave a message.
thanks for the help.