I am trying to create some vector objects which will act as stars on the screen to fly past to the left. At the moment, I cannot get this to work. Can anyone see what I am doing wrong? The screen goes black so I think it may be a directX error but when I take out the push_back line, it works fine. The code below is creating an object and moving it. The code underneath that is the star class (All very simple... or I thought).
stars.push_back(star(SCREEN_WIDTH, SCREEN_HEIGHT));
for (std::vector<star>::iterator IT = stars.begin(); IT != stars.end(); IT++)
{
(*IT).move();
}
class star
{
private:
int yPos;
int xPos;
public:
star(int sw, int sh)
{
yPos = sh/2;
xPos = sw;
}
void move()
{
xPos--;
}
int xPosition()
{
return xPos;
}
int yPosition()
{
return yPos;
}
};
Thanks for the reply. This is how I am drawing the image. Obviously, I am creating the texture before anything is executed.
D3DXCreateTextureFromFile(d3dDevice, "star.png", &starSprite);
Thanks for the reply. This is how I am drawing the image. Obviously, I am creating the texture before anything is executed.
D3DXCreateTextureFromFile(d3dDevice, "star.png", &starSprite);
Seems to have solved my problem though, putting it back in. Should have noticed that really as I have plenty of other sprites using the same method as I am doing this. Thanks for pointing out what i missed!