No unnecessary variables:
bool isBgLoaded = bg.loadFromFile("background.jpg");
if( !isBgLoaded )
// ->
if (!bg.loadFromFile("background.jpg"))
Never use
std::exit()! It performs no cleanup, destructors are not invoked.
exit( 1 );
// ->
return 1;
Use standard library functions from
<algorithm>:
x = ( x < 0 ) ? 0 : x
// ->
x = std::max(x, 0);
Do you really use alternative keywords? Just be aware that Visual Studio doesn't support them, so your code is non-portable.
and
// ->
&&
Make variables that don't change constant. Or no local variables at all, but be consistent.
float pan_speed = 0.8f;
// ->
const float pan_speed = 0.8f;
Get rid of unused include directives.
#include<string>
// ->
Be consistent with your code style. Some constants are
ALL_CAPS, some
standard_style. Personally, I would use
ALL_CAPS only for macros.
Use functions to outsource functionality. Your
main() is way too big.
Declare variables as late and local as possible. The
sf::Event event; declaration remains unused for many lines.