SFML community forums
Help => General => Topic started by: Shriek on August 15, 2011, 01:00:24 pm
-
Hey guys I'm trying to make a 2d rpg, the world is split into 40x40 tiles which can be viewed on the map and each individual area is made of 201x201 tiles. When I run my code it sets the images and positions for the map tiles but when i tell it to set the images and positions for my area tiles it gets to the while loop, looks at it and thinks like "hmmm nah i'm not gonna run that" and then it just stops with 'The thread 'Win32 Thread' (0x454) has exited with code 0 (0x0).'
Here is the code it stops at:
std::vector< std::vector<sf::Sprite> > SpTiles(201,
std::vector<sf::Sprite>(201));
iX = 0;
iY = 0;
fX = 0.f;
fY = 0.f;
// Program stops here
while (iY < 201);
{
SpTiles[iX][iY].SetImage(ImGrass);
SpTiles[iX][iY].SetPosition(fX, fY);
++iX;
fX = fX + 64.f;
if (iX > 200)
{
iX = 0;
++iY;
fX = 0.f;
fY = fY + 64.f;
}
}
-
while (iY < 201);
That looks like an infinite loop, your while loop is empty, iY will always remain zero.
That's because of the semicolon at the end of the line, remove that one. Common programming trap for newcomers. :)
-
Omg i can't believe i missed that >.<, thanks lol.