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

Author Topic: SFML Game Development -- A book on SFML  (Read 259504 times)

0 Members and 1 Guest are viewing this topic.

nikniknaks

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: SFML Game Development -- A book on SFML
« Reply #225 on: June 22, 2014, 09:34:23 am »
Thanks. I might give it  shot. But ah is this thread good for asking question related to c++? like for example when the book uses some technique that is way beyond my knowledge?

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
Re: SFML Game Development -- A book on SFML
« Reply #226 on: June 22, 2014, 09:56:54 am »
But ah is this thread good for asking question related to c++?
Not really. In fact, this whole forum is not, there are better places for language-specific questions (C++ forums or StackOverflow, for example).

If you have semantic questions related to the book, i.e. you do understand the C++ code, but don't know why we made a certain design decision, you can of course ask here.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

nikniknaks

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: SFML Game Development -- A book on SFML
« Reply #227 on: June 22, 2014, 10:27:48 am »
Ow okay.. Thanks by the way..

One last thing. Why no kindle edition? :(

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
Re: SFML Game Development -- A book on SFML
« Reply #228 on: June 22, 2014, 10:33:50 am »
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

SeriousITGuy

  • Full Member
  • ***
  • Posts: 123
  • Still learning...
    • View Profile
Re: SFML Game Development -- A book on SFML
« Reply #229 on: July 02, 2014, 09:46:39 am »
Hey Guys,

I have a problem with the code from chapter 7. I followed the book correctly but I cannot compile the Player-Class because of the following error:
Code: [Select]
1>  Player.cpp
1>c:\development\downloads\sfml game development\07_gameplay\include\book\command.hpp(33): error C3848: expression having type 'const std::_Bind<true,void,std::_Pmf_wrap<void (__thiscall Aircraft::* )(void),void,Aircraft,>,std::_Ph<1> &>' would lose some const-volatile qualifiers in order to call 'void std::_Bind<true,void,std::_Pmf_wrap<void (__thiscall Aircraft::* )(void),void,Aircraft,>,std::_Ph<1> &>::operator ()<GameObject&,sf::Time&>(GameObject &,sf::Time &)'
1>          with
1>          [
1>              GameObject=Aircraft
1>          ]

I use VC2013 with Update 2 to compile this.
What I figured out until now, is that if I comment out the lines 111 and 112 from Player.cpp
        mActionBinding[Fire].action          = derivedAction<Aircraft>(std::bind(&Aircraft::fire, _1));
        mActionBinding[LaunchMissile].action = derivedAction<Aircraft>(std::bind(&Aircraft::launchMissile, _1));
it compiles. The problem lies somehow in the std::bind.

Also in DataTables.cpp I get the following error for the std::bind-statements:
data[Pickup::HealthRefill].texture = Textures::HealthRefill;
        data[Pickup::HealthRefill].action = std::bind(&Aircraft::repair, _1, 25);
       
        data[Pickup::MissileRefill].texture = Textures::MissileRefill;
        data[Pickup::MissileRefill].action = std::bind(&Aircraft::collectMissiles, _1, 3);
       
        data[Pickup::FireSpread].texture = Textures::FireSpread;
        data[Pickup::FireSpread].action = std::bind(&Aircraft::increaseSpread, _1);
       
        data[Pickup::FireRate].texture = Textures::FireRate;
        data[Pickup::FireRate].action = std::bind(&Aircraft::increaseFireRate, _1);

Code: [Select]
1>  DataTables.cpp
1>c:\program files (x86)\microsoft visual studio 12.0\vc\include\functional(1241): error C2100: illegal indirection
1>          c:\program files (x86)\microsoft visual studio 12.0\vc\include\functional(1149) : see reference to function template instantiation '_Rx std::_Pmf_wrap<void (__thiscall Entity::* )(int),_Rx,Entity,int>::operator ()<Aircraft>(_Wrapper &,int) const' being compiled
1>          with
1>          [
1>              _Rx=void
1>  ,            _Wrapper=Aircraft
1>          ]
1>          c:\program files (x86)\microsoft visual studio 12.0\vc\include\functional(1149) : see reference to function template instantiation '_Rx std::_Pmf_wrap<void (__thiscall Entity::* )(int),_Rx,Entity,int>::operator ()<Aircraft>(_Wrapper &,int) const' being compiled
1>          with
1>          [
1>              _Rx=void
1>  ,            _Wrapper=Aircraft
1>          ]
1>          c:\program files (x86)\microsoft visual studio 12.0\vc\include\functional(1137) : see reference to function template instantiation 'void std::_Bind<true,void,std::_Pmf_wrap<void (__thiscall Entity::* )(int),void,Entity,int>,std::_Ph<1> &,int>::_Do_call<Aircraft,0,1>(std::tuple<Aircraft &>,std::_Arg_idx<0,1>)' being compiled
1>          c:\program files (x86)\microsoft visual studio 12.0\vc\include\functional(1137) : see reference to function template instantiation 'void std::_Bind<true,void,std::_Pmf_wrap<void (__thiscall Entity::* )(int),void,Entity,int>,std::_Ph<1> &,int>::_Do_call<Aircraft,0,1>(std::tuple<Aircraft &>,std::_Arg_idx<0,1>)' being compiled
1>          c:\program files (x86)\microsoft visual studio 12.0\vc\include\xrefwrap(283) : see reference to function template instantiation 'void std::_Bind<true,void,std::_Pmf_wrap<void (__thiscall Entity::* )(int),void,Entity,int>,std::_Ph<1> &,int>::operator ()<Aircraft&>(Aircraft &)' being compiled
1>          c:\program files (x86)\microsoft visual studio 12.0\vc\include\xrefwrap(283) : see reference to function template instantiation 'void std::_Bind<true,void,std::_Pmf_wrap<void (__thiscall Entity::* )(int),void,Entity,int>,std::_Ph<1> &,int>::operator ()<Aircraft&>(Aircraft &)' being compiled
1>          c:\program files (x86)\microsoft visual studio 12.0\vc\include\functional(228) : see reference to function template instantiation '_Ret std::_Callable_obj<std::_Bind<true,_Ret,std::_Pmf_wrap<void (__thiscall Entity::* )(int),void,Entity,int>,std::_Ph<1> &,int>,false>::_ApplyX<_Rx,Aircraft&>(Aircraft &)' being compiled
1>          with
1>          [
1>              _Ret=void
1>  ,            _Rx=void
1>          ]
1>          c:\program files (x86)\microsoft visual studio 12.0\vc\include\functional(228) : see reference to function template instantiation '_Ret std::_Callable_obj<std::_Bind<true,_Ret,std::_Pmf_wrap<void (__thiscall Entity::* )(int),void,Entity,int>,std::_Ph<1> &,int>,false>::_ApplyX<_Rx,Aircraft&>(Aircraft &)' being compiled
1>          with
1>          [
1>              _Ret=void
1>  ,            _Rx=void
1>          ]
1>          c:\program files (x86)\microsoft visual studio 12.0\vc\include\functional(226) : while compiling class template member function 'void std::_Func_impl<_MyWrapper,_Alloc,_Ret,Aircraft &>::_Do_call(Aircraft &)'
1>          with
1>          [
1>              _Alloc=std::allocator<std::_Func_class<void,Aircraft &>>
1>  ,            _Ret=void
1>          ]
1>          c:\program files (x86)\microsoft visual studio 12.0\vc\include\functional(495) : see reference to class template instantiation 'std::_Func_impl<_MyWrapper,_Alloc,_Ret,Aircraft &>' being compiled
1>          with
1>          [
1>              _Alloc=std::allocator<std::_Func_class<void,Aircraft &>>
1>  ,            _Ret=void
1>          ]
1>          c:\program files (x86)\microsoft visual studio 12.0\vc\include\functional(396) : see reference to function template instantiation 'void std::_Func_class<_Ret,Aircraft &>::_Do_alloc<_Myimpl,_Ty,_Alloc>(_Fty &&,_Alloc)' being compiled
1>          with
1>          [
1>              _Ret=void
1>  ,            _Ty=std::_Bind<true,void,std::_Pmf_wrap<void (__thiscall Entity::* )(int),void,Entity,int>,std::_Ph<1> &,int>
1>  ,            _Alloc=std::allocator<std::_Func_class<void,Aircraft &>>
1>  ,            _Fty=std::_Bind<true,void,std::_Pmf_wrap<void (__thiscall Entity::* )(int),void,Entity,int>,std::_Ph<1> &,int>
1>          ]
1>          c:\program files (x86)\microsoft visual studio 12.0\vc\include\functional(396) : see reference to function template instantiation 'void std::_Func_class<_Ret,Aircraft &>::_Do_alloc<_Myimpl,_Ty,_Alloc>(_Fty &&,_Alloc)' being compiled
1>          with
1>          [
1>              _Ret=void
1>  ,            _Ty=std::_Bind<true,void,std::_Pmf_wrap<void (__thiscall Entity::* )(int),void,Entity,int>,std::_Ph<1> &,int>
1>  ,            _Alloc=std::allocator<std::_Func_class<void,Aircraft &>>
1>  ,            _Fty=std::_Bind<true,void,std::_Pmf_wrap<void (__thiscall Entity::* )(int),void,Entity,int>,std::_Ph<1> &,int>
1>          ]
1>          c:\program files (x86)\microsoft visual studio 12.0\vc\include\functional(385) : see reference to function template instantiation 'void std::_Func_class<_Ret,Aircraft &>::_Reset_alloc<_Ty,std::allocator<std::_Func_class<_Ret,Aircraft &>>>(_Fty &&,_Alloc)' being compiled
1>          with
1>          [
1>              _Ret=void
1>  ,            _Ty=std::_Bind<true,void,std::_Pmf_wrap<void (__thiscall Entity::* )(int),void,Entity,int>,std::_Ph<1> &,int>
1>  ,            _Fty=std::_Bind<true,void,std::_Pmf_wrap<void (__thiscall Entity::* )(int),void,Entity,int>,std::_Ph<1> &,int>
1>  ,            _Alloc=std::allocator<std::_Func_class<void,Aircraft &>>
1>          ]
1>          c:\program files (x86)\microsoft visual studio 12.0\vc\include\functional(385) : see reference to function template instantiation 'void std::_Func_class<_Ret,Aircraft &>::_Reset_alloc<_Ty,std::allocator<std::_Func_class<_Ret,Aircraft &>>>(_Fty &&,_Alloc)' being compiled
1>          with
1>          [
1>              _Ret=void
1>  ,            _Ty=std::_Bind<true,void,std::_Pmf_wrap<void (__thiscall Entity::* )(int),void,Entity,int>,std::_Ph<1> &,int>
1>  ,            _Fty=std::_Bind<true,void,std::_Pmf_wrap<void (__thiscall Entity::* )(int),void,Entity,int>,std::_Ph<1> &,int>
1>  ,            _Alloc=std::allocator<std::_Func_class<void,Aircraft &>>
1>          ]
1>          c:\program files (x86)\microsoft visual studio 12.0\vc\include\functional(688) : see reference to function template instantiation 'void std::_Func_class<_Ret,Aircraft &>::_Reset<_Ty>(_Fty &&)' being compiled
1>          with
1>          [
1>              _Ret=void
1>  ,            _Ty=std::_Bind<true,void,std::_Pmf_wrap<void (__thiscall Entity::* )(int),void,Entity,int>,std::_Ph<1> &,int>
1>  ,            _Fty=std::_Bind<true,void,std::_Pmf_wrap<void (__thiscall Entity::* )(int),void,Entity,int>,std::_Ph<1> &,int>
1>          ]
1>          c:\program files (x86)\microsoft visual studio 12.0\vc\include\functional(688) : see reference to function template instantiation 'void std::_Func_class<_Ret,Aircraft &>::_Reset<_Ty>(_Fty &&)' being compiled
1>          with
1>          [
1>              _Ret=void
1>  ,            _Ty=std::_Bind<true,void,std::_Pmf_wrap<void (__thiscall Entity::* )(int),void,Entity,int>,std::_Ph<1> &,int>
1>  ,            _Fty=std::_Bind<true,void,std::_Pmf_wrap<void (__thiscall Entity::* )(int),void,Entity,int>,std::_Ph<1> &,int>
1>          ]
1>          c:\development\downloads\sfml game development\07_gameplay\source\datatables.cpp(64) : see reference to function template instantiation 'std::function<void (Aircraft &)> &std::function<void (Aircraft &)>::operator =<std::_Bind<true,void,std::_Pmf_wrap<void (__thiscall Entity::* )(int),void,Entity,int>,std::_Ph<1> &,int>>(_Fx &&)' being compiled
1>          with
1>          [
1>              _Fx=std::_Bind<true,void,std::_Pmf_wrap<void (__thiscall Entity::* )(int),void,Entity,int>,std::_Ph<1> &,int>
1>          ]
1>          c:\development\downloads\sfml game development\07_gameplay\source\datatables.cpp(64) : see reference to function template instantiation 'std::function<void (Aircraft &)> &std::function<void (Aircraft &)>::operator =<std::_Bind<true,void,std::_Pmf_wrap<void (__thiscall Entity::* )(int),void,Entity,int>,std::_Ph<1> &,int>>(_Fx &&)' being compiled
1>          with
1>          [
1>              _Fx=std::_Bind<true,void,std::_Pmf_wrap<void (__thiscall Entity::* )(int),void,Entity,int>,std::_Ph<1> &,int>
1>          ]

When commenting out the lines with the std::bind, everything compiles fine.


I also tried the code from the official download, same problem. Haven't tried the github-code but will do so.
But maybe in the meantime anyone knows why this happens?

Thanks in advance

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
Re: SFML Game Development -- A book on SFML
« Reply #230 on: July 02, 2014, 09:57:57 am »
See here. The GitHub code should work.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

SeriousITGuy

  • Full Member
  • ***
  • Posts: 123
  • Still learning...
    • View Profile
Re: SFML Game Development -- A book on SFML
« Reply #231 on: July 02, 2014, 10:39:15 am »
Just found the compiler bug related to std::bind via Google. Tried the github-code, works fine. Thanks for clearing this so fast. ;)

Cheers!

coldscrip

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: SFML Game Development -- A book on SFML
« Reply #232 on: July 20, 2014, 07:44:02 pm »
I am experiencing lag down to 2 FPS when shooting a lot of bullets. This is the game's code on the last chapter straight from github.  The game runs at a solid 60 fps then I start to get powerups that increase the number of bullets as well as the firerate. If I hold down the fire button and fill the screen with my bullets I sink down to 2 FPS. Anyone else experience such lag?

This is on an i5-3570K 4 core at 3.4ghz
8g RAM
NVIDIA GTX660TI

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
Re: SFML Game Development -- A book on SFML
« Reply #233 on: July 20, 2014, 08:48:58 pm »
As mentioned in the book, the collision algorithm does not scale very well for many objects (that's also why proposed a range of possible extensions). But it seems strange that you're experiencing the lag in normal use, are you compiling in Debug mode or with other checks/debuggers enabled?
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

coldscrip

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: SFML Game Development -- A book on SFML
« Reply #234 on: July 20, 2014, 09:48:18 pm »
I tried the same tests with a release build and things seemed to stay at a consistent 60fps. I understand the implications of the current collision detection system as it does not scale very well. I however lack an understanding as to how a debug build could cause such a great performance hit compared to a release build. Any input would be great.

dabbertorres

  • Hero Member
  • *****
  • Posts: 506
    • View Profile
    • website/blog
Re: SFML Game Development -- A book on SFML
« Reply #235 on: July 20, 2014, 10:15:14 pm »
A debug build does not (usually) make any optimizations, and leaves all the debug information in the executable created, which leaves the computer doing more work for some instructions, thus slowing down execution of the application.

coldscrip

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: SFML Game Development -- A book on SFML
« Reply #236 on: July 20, 2014, 10:21:44 pm »
Thanks guys. It all make quite a bit of sense now. I appreciate it.

blDraX

  • Newbie
  • *
  • Posts: 1
    • View Profile
Re: SFML Game Development -- A book on SFML
« Reply #237 on: August 14, 2014, 07:42:39 pm »
I bought the book and also took a look at the Gamestate Manager. I used a similar system up to now and have a question I couldn't find the answer to in the book: How do you pass information between the states? Consider for example that I have a menu state where I select a level. When I continue to the load level state, I still have to know, which level was chosen in the menu. Or for example a highscore state, where the score is sent to the web and compared with others - how does the highscore state know the score from the game state?

Is the State::Context where you would do this? I rather understood the Context as a collection of pointers to all the technical stuff in the background - not as a place where any game logic happens.

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
Re: SFML Game Development -- A book on SFML
« Reply #238 on: August 14, 2014, 09:49:41 pm »
Is the State::Context where you would do this?
With our design, yes. In general, it would also be possible to pass that information to the constructor of the next state.

I rather understood the Context as a collection of pointers to all the technical stuff in the background - not as a place where any game logic happens.
These pointers are used to access data that persists across states, e.g. resources. You're right that the logic doesn't really happen in State::Context, as the class provides no functionality. You could do this similarly for highscore: store the data/functionality elsewhere, and just reference it in the context.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

one234

  • Newbie
  • *
  • Posts: 1
    • View Profile
    • Apply vietnam visa online
    • Email
Re: SFML Game Development -- A book on SFML
« Reply #239 on: September 09, 2014, 04:44:48 am »
What is required knowledge of c++ to read this?

I know the basics of c++ like pointers reference but dont have an practical experience on it.

Is my knowledge enough?

 

anything