- Joined
- Dec 8, 2005
- Messages
- 6,603
- Age
- 40
- Location
- UK
- Website
- pokeparadox.itch.io
- WEBSITE
- https://github.com/pokeparadox
- YOUTUBE
- pokeparadox
Hi, I'm using vactors in my game. I have some creatures and they grow. I'm using vectors so they can grow indefinately.
I also want these creatures to shrink when another creature eats it... I could just pop_back() but I would rather remove the specific collided cell.
I'm sure there is a way to remove a specific array index in a vector, but I can't seem to figure out how :S
Any clues?
EDIT: I think I have it...
I also want these creatures to shrink when another creature eats it... I could just pop_back() but I would rather remove the specific collided cell.
I'm sure there is a way to remove a specific array index in a vector, but I can't seem to figure out how :S
Any clues?
EDIT: I think I have it...
Code:
void creature::removeNode(int nodeIndex)
{
for (int i = nodeIndex; i < nodes.size() - 1; i++)
{
nodes[i] = nodes[i+1];
}
nodes.pop_back();
}