PDA

View Full Version : matrix



cutekk
02-15-2005, 05:11 AM
first of all, sorry for my stupid question. but i really have no idea about it.

how to write matrix condition in a if else function? as i used the matrix to build walls.

for example,

short matrix[]={ 1,1,1,1,1,1,1,1,1,1,2,1,1,1,1,1,1,1,1,1,
1,1,1,0,0,0,1,1,1,1,0,0,0,1,0,0,0,1,0,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,1,};

if(matrix[???]==1)
{
....
}

so, what should i put with the ? symbol??

thank u very much!!!

ZbuffeR
02-15-2005, 05:47 AM
Put whatever index for which you want to see its value.
This is basic C knowledge, try to find some online simple tutorials for C, it will help a lot :)

cutekk
02-15-2005, 07:22 AM
sry...
the building walls coding is like this,
int k=0;
loop i
loop j
if(matrix[k] == 1)
{
glBegin(GL_QUADS);
.....
glEnd();
}
k++;
glTranslatef(2.0f,0.0f,0.0f);
}
glTranslatef(-40.0f,0.0f,2.0f);
}

so, should i put k for the matrix in the if else condition at somewhere else? or i could write another way round? i have tried so many times including putting k.
pls help me