Skip to main content
added 39 characters in body
Source Link

Hello to anyone reading this. I am having trouble on how to use std::vector. From what I know, std::vector is a flexible version of an array and iterator is used to go through each individual element within a vector.

std::vector<std::vector<int>> row;
std::vector<int> column;
//This is equivalent to... (?)
int array[i][j];

So what if I wanted to use a 2D std::vector for a tilemap?

std::vector<std::vector<int>> row; 
std::vector<int> column;

for (int i = 0; i < row.size(); ++i) {
    for (int j = 0; j < [i]row[i].size(); ++j) {
    //something with map
    }
}

for (itr = row.begin; != row.end(); ++++itr) {
    //something with each block of the map?
}

Sorry if the code is incomplete or wrong. I can't seem to understand the standard format of std::vector and using an iterator.

Thank you to those willing to help.

Hello to anyone reading this. I am having trouble on how to use std::vector. From what I know, std::vector is a flexible version of an array and iterator is used to go through each individual element within a vector.

std::vector<std::vector<int>> row;
std::vector<int> column;
//This is equivalent to... (?)
int array[i][j];

So what if I wanted to use a 2D std::vector for a tilemap?

std::vector<std::vector<int>> row; 
std::vector<int> column;

for (int i = 0; i < .size(); ++i) {
    for (int j = 0; j < [i].size(); ++j) {
    //something with map
    }
}

for (itr = .begin; != .end(); ++) {
    //something with each block of the map?
}

Thank you to those willing to help.

Hello to anyone reading this. I am having trouble on how to use std::vector. From what I know, std::vector is a flexible version of an array and iterator is used to go through each individual element within a vector.

std::vector<std::vector<int>> row;
std::vector<int> column;
//This is equivalent to... (?)
int array[i][j];

So what if I wanted to use a 2D std::vector for a tilemap?

std::vector<std::vector<int>> row; 
std::vector<int> column;

for (int i = 0; i < row.size(); ++i) {
    for (int j = 0; j < row[i].size(); ++j) {
    //something with map
    }
}

for (itr = row.begin; != row.end(); ++itr) {
    //something with each block of the map?
}

Sorry if the code is incomplete or wrong. I can't seem to understand the standard format of std::vector and using an iterator.

Thank you to those willing to help.

added 39 characters in body
Source Link

Hello to anyone reading this. I am having trouble on how to use std::vector. From what I know, std::vector is a flexible version of an array and iterator is used to go through each individual element within a vector.

std::vector<std::vector<int>> row;
std::vector<int> column;
//This is equivalent to... (?)
int array[i][j];

So what if I wanted to use a 2D std::vector for a tilemap?

std::vector<std::vector<int>> row; 
std::vector<int> column;

for (int i = 0; i < .size(); ++i) {
    for (int j = 0; j < [i].size(); ++j) {
    //something with map
    }
}

for (itr = .begin; != .end(); ++) {
    //something with each block of the map?
}

Thank you to those willing to help.

Hello to anyone reading this. I am having trouble on how to use std::vector. From what I know, std::vector is a flexible version of an array and iterator is used to go through each individual element within a vector.

std::vector<std::vector<int>> row;
std::vector<int> column;
//This is equivalent to... (?)
int array[i][j];

So what if I wanted to use a 2D std::vector for a tilemap?

std::vector<std::vector<int>> row; 
std::vector<int> column;

for (int i = 0; i < .size(); ++i) {
    for (int j = 0; j < [i].size(); ++j) {
    //something with map
    }
}

for (itr = .begin; != .end(); ++) {
    //something with each block of the map?
}

Hello to anyone reading this. I am having trouble on how to use std::vector. From what I know, std::vector is a flexible version of an array and iterator is used to go through each individual element within a vector.

std::vector<std::vector<int>> row;
std::vector<int> column;
//This is equivalent to... (?)
int array[i][j];

So what if I wanted to use a 2D std::vector for a tilemap?

std::vector<std::vector<int>> row; 
std::vector<int> column;

for (int i = 0; i < .size(); ++i) {
    for (int j = 0; j < [i].size(); ++j) {
    //something with map
    }
}

for (itr = .begin; != .end(); ++) {
    //something with each block of the map?
}

Thank you to those willing to help.

Source Link

Using 2D std::vector for map and collision

Hello to anyone reading this. I am having trouble on how to use std::vector. From what I know, std::vector is a flexible version of an array and iterator is used to go through each individual element within a vector.

std::vector<std::vector<int>> row;
std::vector<int> column;
//This is equivalent to... (?)
int array[i][j];

So what if I wanted to use a 2D std::vector for a tilemap?

std::vector<std::vector<int>> row; 
std::vector<int> column;

for (int i = 0; i < .size(); ++i) {
    for (int j = 0; j < [i].size(); ++j) {
    //something with map
    }
}

for (itr = .begin; != .end(); ++) {
    //something with each block of the map?
}