Thanks for the help guys. I've managed to find the problem, and it was a DirectX problem related to the Vector, but not the actual Vector itself. I may toss the Vector::clear() method into the destructor, just for peace of mind.
In fixing my problem, I had to re-think the use of my vector, and in doing so, I no longer have a vector of my class, but I have a vector of a struct, within that class:
Code:
struct KINETICS
{
D3DXVECTOR2 Position;
D3DXVECTOR2 Velocity;
D3DXVECTOR2 Boundary;
void Init(int iWidth, int iHeight)
{
int X, Y;
X = (rand() / ((RAND_MAX / iWidth) + 1));
Y = (rand() / ((RAND_MAX / iHeight) + 1));
Position = D3DXVECTOR2((float)X, (float)Y);
Velocity = D3DXVECTOR2(3.0f, 3.0f);
Boundary = D3DXVECTOR2((float)iWidth, (float)iHeight);
}
void Update(void)
{
if(Position.x < 0.0f)
{
Position.x = Boundary.x;
}
else if(Position.x > Boundary.x)
{
Position.x = 0.0f;
}
if(Position.y < 0.0f)
{
Position.y = Boundary.y;
}
else if(Position.y > Boundary.y)
{
Position.y = 0.0f;
}
Position = Position + Velocity;
}
};
class cORGANISM
{
public:
cORGANISM(void);
virtual ~cORGANISM(void);
HRESULT Initialise(IDirect3DDevice9 *pD3DDevice);
void Render(void);
private:
IDirect3DDevice9 *m_pD3DDevice;
IDirect3DTexture9 *m_pTexture;
ID3DXSprite *m_pSprite;
std::vector<KINETICS> Movement;
};
And it's working nice and dandy. I'm up to having 100 of these organisms travelling across the screen, but I've hit a barrier in capabilities (200 organisms and the frame rate drops very noticeably). But that's for another discussion somewhere else
I am curious though, how it is okay that I am doing this, when creating my Vector of 100 Movement variables:
Code:
Movement.push_back(KINETICS());
I did that as a hunch when converting my code. I wasn't aware that structs had constructors...