I'm doing a small console rpg in c + +.
In this rpg just have to move a letter "p" by a matrix (two-dimensional) until you reach the letter "M".
The problem appears to generate the array. I think it's easy, the problem is that the ion Assignment I copied below (void generarmapa (game & board)) the array always takes the same value ("H") and all others are ignored.
Can someone explain why this happens?
Is there another way to assign these values?
Thank you very much ^ ^
sorry for the possible bad writing of the text, I do not speak much English, I do what I can, I will gradually improve
typedef std::vector< std::vector< int > > juego;
void generarmapa(juego &tablero){
for(int y=0;y<19;y++ ){
tablero[0][y] ='H','H','H','H','H','H','H','H','H','H','H','H','H','H','H','H','H','H','H';
}
for(int y=0;y<19;y++ ){
tablero[1][y] ='H','P','H','H','H','H','H',' ',' ',' ',' ',' ','O','H','H','H','H','H','H';
}
for(int y=0;y<19;y++ ){
tablero[2][y] ='H',' ','H',' ',' ',' ',' ',' ','H','H','H','H','H','H','H','H','H','H','H';
}
for(int y=0;y<19;y++ ){
tablero[3][y] ='H',' ','H',' ','H','H','H','E',' ','H','H','H',' ',' ',' ',' ','B',' ','M';
}
for(int y=0;y<19;y++ ){
tablero[4][y] ='H',' ','E',' ','H','H','H',' ','H','H','H','H',' ','H','H','H','H','H','H';
}
for(int y=0;y<19;y++ ){
tablero[5][y] ='H','H','H','H','H','H','H',' ','H','H','H','H',' ','H','H','H','H','H','H';
}
for(int y=0;y<19;y++ ){
tablero[6][y] ='H','H','H','H','H','H','H',' ','H','H','H','H',' ','H','H','H','H','H','H';
}
for(int y=0;y<19;y++ ){
tablero[7][y] ='H','H','H','H','H','H','H',' ',' ',' ','E',' ',' ','H','H','H','H','H','H';
}
for(int y=0;y<19;y++ ){
tablero[8][y] ='H','H','H','H','H','H','H','H','H','H','H','H','H','H','H','H','H','H','H';
}
}
juego dimensionar_vector(juego &tablero) {
int tamañovector=19;
tablero;
tablero.resize( tamañovector );
for(int i=0; i < 9; ++i) {
tablero[i].resize(tamañovector);
}
return tablero;
}
Edited by mayoscuro, 24 October 2012 - 12:13 PM.






