Hello Guys I am going to implement dijktra's algorithm and I really need to show up some walkable and unwalkable tiles on screen. I am having a great problem doing this because, every time I draw the tile nothing appears. I suspected somehow that the implementation I made in loading that vector is wrong and that it loses reference as soon the loop ends. I badly need help on this one..
This is how I populate the grid with walkable tiles as the default tileset
shared_ptr< Tile > tmp;
for( int y = 0; y < grid_height; y++ )
{
tset.push_back( vector< shared_ptr< Tile > >() );
for( int i = 0; i < grid_width; i++ )
{
tmp.reset( new Tile( "walkable.png" , 50 ) );
tset[ y ].push_back( tmp );
}
}
this is how I draw it.
void Grid::populateGrid()
{
int dist_y = 0;
int dist_x = 0;
for( int y = 0; y < grid_height; y++ )
{
for( int i = 0; i < grid_width; i++ )
{
tset[ y ][ i ].get()->setTexture( wTile );
tset[ y ][ i ].get()->setPosition( dist_x , dist_y );
dist_x += tilesize;
}
dist_x = 0;
dist_y += tilesize;
}
}