1) So I have a quick question about game loops. Is it better to do a
1 2 3 4 5 6 7 8 9 10 11 12
bool shouldExit == false;
while (shouldExit == false)
{
... // program
//psuedo
// playAgain?
// if playAgain is yes
// return true;
// if playAgain is no
// return false;
}
or would it be better to do something like a do-while loop so:
1 2 3 4 5 6
do
{
// program
// ask user to play again and check to see if they want to...
// return true if yes or false if no
}while(playAgain == true)
2) I'm running into issues setting up sfml for the first time. I followed this step by step http://www.sfml-dev.org/tutorials/1.6/start-vc.php, and when i tried to run their simple program I tried to run it and it gave some issue with the sfml-system.dll and the source says that you need to include it in the executable directory, how do I find the executable directory? A step by step to get there would be much appreciate. Thanks in advance!
1) There's no difference. However, you should write while (!shouldExit) and while (playAgain).
2) The executable should be somewhere in the project's folder (possibly in a subdirectory called bin or dist).
oh oops, i meant to write bool shouldExit = false;
@Athar
When I try to compile it, it gives this error.
stflTest.exe - System Error
The program can't start because sfml system.dll is missing from your computer. Try re-installing the program to fix this problem.
When it says to re-install the program is that refering to re-installing visual studio (since that's what i'm using)? or is there a way around re-installing it. I mean if I'm gonna have to re-install it might as well look into visual studio 10 right? since right now i just have 8
Did you really follow the step by step directions on that site? =x because I did that and it worked fine.
In particular... did you notice this part?
Important: for the Debug configuration, you have to link with the debug versions of the libraries, which have the "-d" suffix (sfml-system-d.lib in this case). If you don't, you may get undefined behaviours and crashes.
Though a simple lib, SFML's awfully hard to set up if it's your first go at it. Visual Studio has lots of tedious settings that you've got to be familiar with.
Post the code you're compiling, maybe the error you're getting is a source issue.
Oh right, those.
There's two ways to 'connect' your project to SFML, they're called static and dynamic linking. Static linking is where all of SFML, or any other lib, would be copied into your executable. On the other hand, dynamically linking means you have to include the .dll files in the same directory as your executable, because it doesn't copy them, rather depends on the external file. ... Or it's the other way around. I've always gotten those two terms mixed up.
Anyway, the way SFML has it organized is it made a few different version of the .lib files. ones with the '-s' prefix mean they'll be linked statically (generally, i never use these, it racks up the size of me .exe). The '-d' tag means Debug, which i've never used either, though i'm sure it has a purpose. Having no tag implies that the lib will be linked dynamically, which is what I always use.
Generally, you won't need any of the tags. In the project options tab, under linker->input, in the Additional Dependencies box, you'll need 'sfml-system.lib', and that's it.
@Thumper I did do the sfml-system.lib, and i get the error, before it said the sfml system-dll was missing. Now it's giving me the other error, and i'm not sure what the problem is. It never gets to the program, just dies. is that because it's not sfml-system-d.lib?
It shouldn't be because you're not using sfml-system-d.lib, and now I've no idea why your code isn't running.
I guess we have to wait 'till the SFML master Disch wakes up. Or someone else that's run into this before comes along.
Anyway, the way SFML has it organized is it made a few different version of the .lib files. ones with the '-s' prefix mean they'll be linked statically (generally, i never use these, it racks up the size of me .exe)
I prefer static linking whenever reasonable, as it makes distribution much simpler.
And in fact, linking statically might solve this problem. I suspect it's because he's linking to the wrong DLL.
ERanz21 wrote:
i don't understand what it's talking about with the -d suffix and what not.
There was a step when you want into project settings and typed "sfml-system.lib" in. This tells VS to link to SFML.
The thing is, your project has 2 builds: one is "Release" and one is "Debug". The Dubug build is slower and bigger, but allows for you do run the debugger which lets you set breakpoints and stuff. The "Release" build is smaller/faster and is intended to be the program you distribute to other people.
SFML also has "Debug" and "Release" versions. What I suspect is happening is you are building a Debug program and linking to the Release version of SFML -- which can cause your program to crash.
For your Debug build, you need to link to the Debug SFML. You do this by linking to "sfml-system-d.lib" instead.
@Dish
Fair enough. When i static link sometimes i get these nasty link errors, so i just don't bother.
and *slaps face* I hadn't thought of that. I set my builds to release subconciously.
EDIT: 'cos you are. And jump on IRC if you're gonna be on a bit longer, i'm bored out of my mind.
that's the one i was using, and it doesn't work. Does it have to be in the same folder as where i have my programs, or does it have to be in the visual studio folder, if there is one, lol?