Might as well do a mini code review.
- First, when posting code here, put it in code tags so it gets properly formatted and highlighted. When you post there's a "Code" dropdown that lets you select the language, so you can get tags that do this:
sf::Texture texture;
if (!texture.loadFromFile("hag.png"))
{
return 0;
}
Makes it much easier for people to read your code.
- Make sure you've read *all* of the official SFML tutorials (even ones you don't think you'll need, they're not long), and check out what's available in the SFML wiki (
https://github.com/SFML/SFML/wiki/Sources) and in Thor (
http://www.bromeon.ch/libraries/thor/) since there's a good chance you can save yourself some time by using existing SFML code.
- When an error happens, always print
something to cout or cerr so you're not completely lost if the error ever starts happening.
- lngRow/lngCol might not be the best variable names. You appear to be using them to represent x/y coordinates rather than row/column indices, and I have no idea what "lng" means. If it's meant to be an abbreviation, don't be afraid of writing out long variable names.
- Though it's not an issue yet, it would be a good idea even at this early stage to take some of that code out of the main() loop and into a separate function or class. The obvious candidate is a Level class that initializes the texture and sprite in its constructor, and has an draw() method (taking a window as an argument) which contains the while(lngCol < 800) {} loop. This will make it easier to change how you handle the tile-based levels in the future (try using multiple sprites, experiment with vertex arrays, etc) without the risk of messing up unrelated logic. And yes, it's worth getting into these refactoring habits even on tiny projects like this.
- Speaking of while(lngCol < 800), that 800 is a magic number. It's best to define it at the top (or in your Level class) as const int LEVEL_HEIGHT = 800; and then say while(lngCol < LEVEL_HEIGHT).