I've startet with an Irrlicht based game some days ago and I'm new to Irrlicht usage and I'm not a very good C++ developer.
So I use irr::core::list<T> to store the player's weapons (following method is a quick temporary one to achieve early results):
Code: Select all
void Player::addWeapon(f32 damage)
{
Weapon* weapon = new Weapon(damage);
mWeapons.push_back( weapon );
if(mWeapons.getSize() == 1)
mCurrentWeapon = mWeapons.begin();
}
Code: Select all
Player::~Player()
{
list<Weapon*>::Iterator i;
for(i = mWeapons.begin(); i != mWeapons.end(); i++)
{
delete (*i);
}
}
Additionaly this is an excerpt of declaration of the class Player:
Code: Select all
list<Weapon*> mWeapons;
list<Weapon*>::Iterator mCurrentWeapon;
Does anyone knows a solution to my problem? I would be happy if someone could help.
btw, sorry for eventually incorrectniss of words and grammar, im not from an english speaking country