Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Why does my program suddenly stop working?  (Read 1645 times)

0 Members and 1 Guest are viewing this topic.

Shriek

  • Newbie
  • *
  • Posts: 4
    • View Profile
Why does my program suddenly stop working?
« 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:

Code: [Select]

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;
}
}

pdinklag

  • Sr. Member
  • ****
  • Posts: 330
  • JSFML Developer
    • View Profile
    • JSFML Website
Why does my program suddenly stop working?
« Reply #1 on: August 15, 2011, 01:15:01 pm »
Code: [Select]
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. :)
JSFML - The Java binding to SFML.

Shriek

  • Newbie
  • *
  • Posts: 4
    • View Profile
Why does my program suddenly stop working?
« Reply #2 on: August 15, 2011, 01:45:57 pm »
Omg i can't believe i missed that >.<, thanks lol.

 

anything