SFML community forums

General => General discussions => Topic started by: Krozark on June 01, 2015, 02:55:14 pm

Title: SFML Blueprints - Another SFML book
Post by: Krozark on June 01, 2015, 02:55:14 pm
Hello!

I am glad to announce you that the book on the SFML SFML Blueprints has been published.

As previous books on SFML, it's published by Packt and is available at the following address:https://www.packtpub.com/game-development/sfml-blueprints (https://www.packtpub.com/game-development/sfml-blueprints).

This book was written by myself and discusses about different points.
Thus we can find different topics such as:


This book contains 8 chapters and each one includes at least one project, and is accompanied by the source code that you can modify as desired.

Here are some screens of different projects:
Chapitre 3
(https://raw.githubusercontent.com/Krozark/SFML-book/master/screen/Chapter3a-min.png)
Chapitre 4 (line cleaning not enable for this screen shot)
(https://raw.githubusercontent.com/Krozark/SFML-book/master/screen/Chapter4-min.png)
Chapitre 7 + 8
(https://raw.githubusercontent.com/Krozark/SFML-book/master/screen/Chapter8b-min.png)

I hope this book will help developers create games that wish.
Title: Re: SFML Blueprints - Another SFML book
Post by: SpeCter on June 01, 2015, 03:23:12 pm
Bought it the moment it was published. Just skimmed through it(not enough time atm), but i like it so far.
Will probably give a better preview when I have time.

Anyways... congrats on publishing it ;)
Title: Re: SFML Blueprints - Another SFML book
Post by: Lo-X on June 01, 2015, 04:34:11 pm
Awesome!

I buy it as soon as my kindle battery is filled up! I'll give full feedback as soon as I read it. But just looking at the summary, it sounds like it completes the previous book by taking another road to the same results. I can't wait :)
Title: Re: SFML Blueprints - Another SFML book
Post by: Krozark on June 02, 2015, 10:06:07 am
Indeed.
The idea was not to replace the previous book, but to complete it by showing new topics.
Do not hesitate to give me your feedback.
Title: Re: SFML Blueprints - Another SFML book
Post by: Mario on June 02, 2015, 11:09:53 am
Seems like your Tetris implementation fails horribly. :D
Title: Re: SFML Blueprints - Another SFML book
Post by: Krozark on June 02, 2015, 01:57:58 pm
The screen shot of the Tetris was actually made by disabling the line cleaning. So don't worry, it's just for the screen shot ;)
Title: Re: SFML Blueprints - Another SFML book
Post by: SpeCter on June 02, 2015, 02:58:22 pm
Isn't the screenhot part of the sample Box2D Integration?
Title: Re: SFML Blueprints - Another SFML book
Post by: Lo-X on June 02, 2015, 03:16:56 pm
Isn't the screenhot part of the sample Box2D Integration?

I guess it is and I think it's nice to demonstrate how "real" physics would do when applied to that game :p
Title: Re: SFML Blueprints - Another SFML book
Post by: SeriousITGuy on June 03, 2015, 07:59:16 am
Already preordered it last month, nice to see it published now. Can't wait to read the advanced topics like Box2D Physics in cooperation with SFML, SFGui and Multi-threading. After finishing "SFML Game Development" this seems to be the next step on the learning curve.
Thanks in advance ;)
Title: Re: SFML Blueprints - Another SFML book
Post by: Krozark on June 03, 2015, 10:12:42 am
Isn't the screenhot part of the sample Box2D Integration?

Exactly  ;)
Title: Re: SFML Blueprints - Another SFML book
Post by: devilswin on June 08, 2015, 05:11:02 pm
When i get enough i will definitely buy this book!

One request, can you post a larger version of the third picture, i want to see more of what it looks like.

Great work, so excited to read it! :)
Title: Re: SFML Blueprints - Another SFML book
Post by: Krozark on June 08, 2015, 05:30:36 pm
Glade to know that you are interested in it.
And don't hesitate to give your feedback  ;).

You can find some screens here : https://github.com/Krozark/SFML-book/tree/master/screen (https://github.com/Krozark/SFML-book/tree/master/screen).
Title: Re: SFML Blueprints - Another SFML book
Post by: zombox on September 11, 2015, 10:21:59 pm
I have problem with compiling source. Anybody could share compiled .exes?
Title: Re: SFML Blueprints - Another SFML book
Post by: Jesper Juhl on September 11, 2015, 10:25:16 pm
Perhaps you should explain what exact problems you have compiling the sources. That might actually result in useful answers and help other people. Just sending you binaries will not.
Title: Re: SFML Blueprints - Another SFML book
Post by: zombox on September 12, 2015, 03:48:36 am
I'm using VS13 and encountered few problems. Actually I managed to compile few first projects, but it took some time.
- VS doesn't support constexpr, so i have to remove it
- i had to replace logical operators written like this: 'not', 'and'.. to '!', '&&'
- for example in 03_Android there're missing constructors
- i had some problems with GLEW references

It's a lot of fuss just tu run these project.

Would be great if somebody knew how to handle problem with logical operators.
Title: Re: SFML Blueprints - Another SFML book
Post by: eXpl0it3r on September 12, 2015, 11:28:40 am
- i had to replace logical operators written like this: 'not', 'and'.. to '!', '&&'

Would be great if somebody knew how to handle problem with logical operators.
It has been pointed out to the author before the book was released, but the report was not taken seriously...
Title: Re: SFML Blueprints - Another SFML book
Post by: select_this on September 12, 2015, 01:48:24 pm
It's possible to get VS to understand alternative operator tokens, according to http://stackoverflow.com/questions/24414124/why-does-vs-not-define-the-alternative-tokens-for-logical-operators (http://stackoverflow.com/questions/24414124/why-does-vs-not-define-the-alternative-tokens-for-logical-operators). Even so, as far as I'm aware their usage isn't all that common (except where I work right now, where the coding standard mandates their use...)
Title: Re: SFML Blueprints - Another SFML book
Post by: Nexus on September 12, 2015, 03:21:38 pm
99.9% of C++ projects avoid those keywords, it's well-known that they're not portable. Unfortunately it seems like not even Visual Studio, one of the most widely used IDEs, has been used for testing...
Title: Re: SFML Blueprints - Another SFML book
Post by: SpeCter on September 12, 2015, 03:25:03 pm
I have to admit, that I didn't even know these alternative keywords existed and I use C/C++ for quite some time now(~15 years):o
Title: Re: SFML Blueprints - Another SFML book
Post by: Jesper Juhl on September 12, 2015, 03:31:34 pm
I have to admit, that I didn't even know these alternative keywords existed and I use C/C++ for quite some time now(~15 years):o
If you want to write really wonky looking code there's also digraphs and trigraphs (https://en.m.wikipedia.org/wiki/Digraphs_and_trigraphs) to play with ;)
Title: Re: SFML Blueprints - Another SFML book
Post by: Krozark on September 12, 2015, 04:29:57 pm
99.9% of C++ projects avoid those keywords, it's well-known that they're not portable. Unfortunately it seems like not even Visual Studio, one of the most widely used IDEs, has been used for testing...

I've point this in the first chapter of the book. Visual studio doesn't sported full C++11 (VS 2013), and some feature not supported where required (don't remember which one).
You can use mingw our clang (as suggested in the same chapter), and all will  be fine (tested on linux/windows).
Title: Re: SFML Blueprints - Another SFML book
Post by: Jesper Juhl on September 12, 2015, 04:39:26 pm
Doesn't change the fact that using stuff like 'not' and 'and' is uncommon, weird, not well supported and generally avoided.
It's really not something you'd want to use in a modern C++ book.
Title: Re: SFML Blueprints - Another SFML book
Post by: Krozark on September 12, 2015, 04:47:40 pm
Those operators are specified in the standard. I don't see why I should avoid them. All the good compiler support them.
And if you really want to use visual studio, you can activate them with a flag, but I don't remember which on.
EDIT : the flag is /Za according to https://msdn.microsoft.com/en-us/library/vstudio/2e6a4at9%28v=vs.110%29.aspx
Title: Re: SFML Blueprints - Another SFML book
Post by: Jesper Juhl on September 12, 2015, 04:54:23 pm
You should avoid them since they are very rarely used and even many experienced C++ developers don't know they exist.
They are a legacy from a time where many systems couldn't type characters like "!", "{" and "|". These days they should just be avoided. C++17 even removes (not just deprecate) a lot of that old cruft.
It's like "the 80's called; they want their trigraphs back" ;)
Title: Re: SFML Blueprints - Another SFML book
Post by: zombox on September 13, 2015, 12:13:18 am
I've point this in the first chapter of the book. Visual studio doesn't sported full C++11 (VS 2013), and some feature not supported where required (don't remember which one).
You can use mingw our clang (as suggested in the same chapter), and all will  be fine (tested on linux/windows).
I tried mingw, but I'm getting:
Code: [Select]
[ 15%] Built target Box2D
Linking CXX shared library ..\..\..\lib\sfgui.dll
CMakeFiles\sfgui.dir/objects.a(Button.cpp.obj):Button.cpp:(.text+0x1d8): undefin
ed reference to `_imp___ZN2sf6StringaSERKS0_'
CMakeFiles\sfgui.dir/objects.a(Button.cpp.obj):Button.cpp:(.text+0x8a2): undefin
ed reference to `_imp___ZNK2sf6String7getSizeEv'
C:\MinGW\bin/ld.exe: CMakeFiles\sfgui.dir/objects.a(Button.cpp.obj): bad reloc a
ddress 0x12 in section `.text$_ZNSt12__shared_ptrIN3sfg6ButtonELN9__gnu_cxx12_Lo
ck_policyE2EED2Ev[__ZNSt12__shared_ptrIN3sfg6ButtonELN9__gnu_cxx12_Lock_policyE2
EED2Ev]'
collect2.exe: error: ld returned 1 exit status
extlibs\SFGUI\CMakeFiles\sfgui.dir\build.make:1996: recipe for target '../lib/sf
gui.dll' failed
mingw32-make[2]: *** [../lib/sfgui.dll] Error 1
CMakeFiles\Makefile2:124: recipe for target 'extlibs/SFGUI/CMakeFiles/sfgui.dir/
all' failed
mingw32-make[1]: *** [extlibs/SFGUI/CMakeFiles/sfgui.dir/all] Error 2
Makefile:116: recipe for target 'all' failed
mingw32-make: *** [all] Error 2
Title: Re: SFML Blueprints - Another SFML book
Post by: Krozark on September 13, 2015, 12:49:08 am
They are a legacy from a time where many systems couldn't type characters like "!", "{" and "|". These days they should just be avoided. C++17 even removes (not just deprecate) a lot of that old cruft.
It's like "the 80's called; they want their trigraphs back" ;)

You're wrong.
C++17  rewove Trigraph ( ??<, ??( ,...) that's true.
But here we are speaking of the alternative operators (and, or, not, xor, bit_or, ...) of standard ISO C++  created a while ago.

I understand that it can be confusing at first but, we are talking about a book. And the goal of it is to learn some new thing to the reader. Maybe it can be the first one.

Personally I think that it's more readable, and you avoid mistakes like "|" instead of "||".
I don't know any reason to avoid them, now if there is a real one (and don't say "Nobody is using it, so don't") please let me know.

I tried mingw, but I'm getting

I'm not able to reproduce your link error. Can you share your compiler version.
It look like a linker error on sfgui.
Did you take the code here : https://github.com/Krozark/SFML-book ?
Title: Re: SFML Blueprints - Another SFML book
Post by: zombox on September 13, 2015, 01:55:13 am
@Krozark
4.8.1 and the code is from repo. Since you compiled, could you just share binaries?
Title: Re: SFML Blueprints - Another SFML book
Post by: Krozark on September 13, 2015, 03:48:39 pm
Since you compiled, could you just share binaries?

I've add them here : https://github.com/Krozark/SFML-book/tree/master/bin/win64 (build on windows 8 x64)
Title: Re: SFML Blueprints - Another SFML book
Post by: Nexus on September 13, 2015, 03:55:11 pm
Personally I think that it's more readable, and you avoid mistakes like "|" instead of "||".
Every C++ programmer knows && and ||. 1% of C++ programmers know and and or. So it is not more readable to most developers.

I don't know any reason to avoid them, now if there is a real one (and don't say "Nobody is using it, so don't") please let me know.
If you don't believe that many C++ developers are confused by those keywords, then at least accept that the probably most widely used C++ IDE does not support them by default. It's of course your decision what you want to support and what not, but you unnecessarily limit your audience.
Title: Re: SFML Blueprints - Another SFML book
Post by: Krozark on September 13, 2015, 04:06:18 pm
If you don't believe that many C++ developers are confused by those keywords

I've admit this in a previous message :
I understand that it can be confusing at first

then at least accept that the probably most widely used C++ IDE does not support them

I only tried Code::Block and Visual Studio as IDE for C++, so I can only speak for them (I personally, used GVim). The first on support them completely (without any changes), and the second on with the flag /Za.
The reason that Visual studio don't support them by default is to be compatible with C (according to my research on the subject). But we make C++ not C, so ...
Title: Re: SFML Blueprints - Another SFML book
Post by: Jesper Juhl on September 13, 2015, 05:57:22 pm
They are a legacy from a time where many systems couldn't type characters like "!", "{" and "|". These days they should just be avoided. C++17 even removes (not just deprecate) a lot of that old cruft.
It's like "the 80's called; they want their trigraphs back" ;)

You're wrong.
C++17  rewove Trigraph ( ??<, ??( ,...) that's true.
But here we are speaking of the alternative operators (and, or, not, xor, bit_or, ...) of standard ISO C++  created a while ago.
They have been there since C++98, not exactly a recent addition. And they've been in C even longer IIRC (<iso646.h>)
But they have always been alternative operators intended to be used when you either cannot input the primary ones or if the source file is using an encoding where the primary ones cause trouble. As far as I understand they have never been intended for use except when you have to.

I understand that it can be confusing at first but, we are talking about a book. And the goal of it is to learn some new thing to the reader. Maybe it can be the first one.
IMHO a good book shouldn't teach bad habits and teaching people to use operator names that almost noone actually use and which will confuse other programmers is a bad thing.

And for the record, I wouldn't consider this to be more readable:
%:include <iostream>
 
int main(int argc, char *argv<::>)
<%
    if (argc > 1 and argv<:1:> not_eq NULL) <%
        std::cout << "Hello, " << argv<:1:> << '\n';
    %>
%>
not even if you stick to just 'and' and 'not_eq' in the above (example from here (http://en.cppreference.com/w/cpp/language/operator_alternative)).

But whatever. I don't want to argue this any further.
Title: Re: SFML Blueprints - Another SFML book
Post by: Jesper Juhl on September 13, 2015, 06:16:22 pm
By the way: Congratulations on actually finishing a book :)
I guess I should go buy and read it ;)
Title: Re: SFML Blueprints - Another SFML book
Post by: Krozark on September 13, 2015, 06:24:24 pm
I'm totally agree with you concerning the usage of digraphs and trigraphs.
Concerning the alternatives keywords, this is another story.
I've came to the point that this is maybe like the indentation (tabs / spaces) or comparison order (var == value / value == var)  : just different point of view.

By the way: Congratulations on actually finishing a book :)

Thanks !
Title: Re: SFML Blueprints - Another SFML book
Post by: Hiura on September 13, 2015, 07:52:20 pm
Concerning the alternatives keywords, this is another story.
I've came to the point that this is maybe like the indentation (tabs / spaces) or comparison order (var == value / value == var)  : just different point of view.

That's exactly what it is to me. Some teach `and` and some teach `&&` to their pupils/readers. Sometimes you use one style for a specific context, and another style for another context. It's especially important when you start writing code for the first time: you need something that is easily understandable to you and in this case `and` is much more readable that `&&` IMO. So I wouldn't call *that* bad practice.
Title: Re: SFML Blueprints - Another SFML book
Post by: Jesper Juhl on September 13, 2015, 08:05:53 pm
I'm calling it "bad practice" since it's different from what 99% of other C++ programmers use. Thus it's prone to cause confusion. It's also not supported by default by Visual Studio (which is again a barrier) and no, "/Za" does not really fix that since it has other implications as well.
It's simply a bad, non(defacto)-standard, confusing, choice to teach.
Title: Re: SFML Blueprints - Another SFML book
Post by: Hiura on September 13, 2015, 08:23:34 pm
Because one IDE doesn't respect the standard we should not use a standard feature? (I've heard that including <ciso646> would make VS happy but never could try...) To me it's not a strong argument.
Title: Re: SFML Blueprints - Another SFML book
Post by: Jesper Juhl on September 13, 2015, 08:27:58 pm
I personally consider the "not known/used by most (any that don't have to?) C++ programmers" the strongest argument.
It's obscure, rarely used and bound to cause confusion.
VS non-default support just adds to the argument.
Title: Re: SFML Blueprints - Another SFML book
Post by: Krozark on September 14, 2015, 10:04:30 am
I propose to stop the conversation about alternative tokens,as we totally derived from the topic of this thread.
It seems obvious that everyone has a different point of view, and this will not change.
Title: Re: SFML Blueprints - Another SFML book
Post by: Nexus on September 14, 2015, 11:27:09 pm
Yes, let's move on, the discussion is really running in circles ;)
Title: Re: SFML Blueprints - Another SFML book
Post by: PewPew on September 15, 2015, 05:59:10 pm
Hi,

Uhm did you add some shaders in the book?
Title: Re: SFML Blueprints - Another SFML book
Post by: Krozark on September 15, 2015, 06:08:29 pm
No as it was already detail in another SFML book (the first one).
Title: Re: SFML Blueprints - Another SFML book
Post by: LanceJZ on October 25, 2015, 01:54:31 am
Hi, I'm on chapter 7 and I'm having an issue building the library for SFML-utils-es I get an error code C2065 'ENTITY': undeclared identifier in line 104. I'm using VS 2015. That error seems to cause 78 other errors in EntityManager.hpp/EntityManager.tpl related to that. There are no other errors in other headers.
I got the SFML-utils-core library to compile just fine. I have not tried the others yet. I changed all the 'and' to &&, 'or' to || and 'not' to ! to do so. As it should have been in the first place.
If you could help, I could maybe learn something. I've been working on this for two days with no luck.

I'm also unable to compile the cpp-utils library. On sys.cpp on line 8 I get PATH_MAX : undeclared identifier and other errors all in sys.cpp.
I also fixed a typo, you had __WIN32 instead of _WIN32 in one of your #ifdef Ln 423.
I would like to be able to compile all of these.
Thank you.
Title: Re: SFML Blueprints - Another SFML book
Post by: Krozark on October 26, 2015, 09:32:37 am


Edit :  PATH_MAX is define by windows headers.




Title: Re: SFML Blueprints - Another SFML book
Post by: LanceJZ on October 27, 2015, 11:02:45 pm
Those files are not included with the book, you have us download from your github site... Don't you even remember your own book? x.x
I want to use Visual Studio 2015, that is the one I plan on using in my games. I am not learning to do it your way, I want to learn how to do it my way...
Title: Re: SFML Blueprints - Another SFML book
Post by: SpeCter on October 28, 2015, 09:36:57 am
Those files are not included with the book, you have us download from your github site... Don't you even remember your own book? x.x
I want to use Visual Studio 2015, that is the one I plan on using in my games. I am not learning to do it your way, I want to learn how to do it my way...

You can download the code files from packt, so basically they "ship" with the book, but since they more often than not ship with the initial version of the code and not the ones which contains fixes made after the book release it is adviced to download them from github...
Title: Re: SFML Blueprints - Another SFML book
Post by: HoodedSpectre on December 19, 2016, 10:15:04 pm
I've been working through your book and I'm getting this error.... ActionTarget is not a template type. Followed exactly how you have it in the book if you need the code here it is. Any suggestions? I'm using CodeLite I don't know if that makes a difference.

#ifndef _ACTIONTARGET_H
#define _ACTIONTARGET_H

#include "ActionMap.h"

#include <functional>
#include <utility>
#include <list>

template<typename T = int>
class ActionTarget
{
public:
    ActionTarget(const ActionTarget<T>&) = delete;
    ActionTarget<T>& operator=(const ActionTarget<T>&) = delete;
   
    using FuncType = std::function<void(const sf::Event&)>;
   
    ActionTarget(const ActionMap<T>& map);
   
    bool ProcessEvent(const sf::Event& event) const;
    void ProcessEvents() const;
   
    void Bind(const T& key, const FuncType& callback);
    void Unbind(const T& key);
   
private:
    std::list<std::pair<T, FuncType>> m_EventsRealTime;
    std::list<std::pair<T, FuncType>> m_EventsPoll;
   
    const ActionMap<T>& m_ActionMap;
   
};

#include "ActionTarget.tpl"

#endif // _ACTIONTARGET_H
Title: Re: SFML Blueprints - Another SFML book
Post by: sandglass on August 18, 2018, 02:13:08 pm
I know that this topic has not been posted for lots of days and probably closed, but I have to write it somewhere to chill out.

I've bought this book recently in anticipation to find a simple way for a noob like me to learn how to make games using SFML in C++. Thats all I wanted. So I started to study this book. I ended up spending more time debugging and stitching together incomplete or sometimes even missed code presented in the book, rather than focusing my mind on the game making of things. Currently I am on page 39 and what can I say... I find it difficult to follow as book's focus is shifted more towards fancy C++ tricks rather than SFML game making ... Boy the author made it so damn difficult. I understand the author knows C++ subject in depth and good at it, and that is alright. BUT GOD DAMN IT! If I wanted to buy a book "Learn how to go ballistic with C++ coding" or "How to be hardcore with C++ OOP and templates" I would look for that specific book!

Author, mate, whats wrong with you dude? If you want to show off your C++ skills or knowledge of different C++ standards, you could have just written a separate book about that, without killing the joy of making games, correct? Why didn't you just wrote a book about making games using SFML and simple C++, and focus on actual SFML game making with short examples and results on the SCREEN? Man I am on page 50 of your book and I still see that small blue rectangle in black window, that does not move and does nothing at all LOL ;)... Damn that is discouraging my brother...

Please C++ coders, may I ask you please, if you write books about Games making write about Games making (no need to kill the fun of making games with hardcore C++ tricks), or if you want to write about deep C++ OOP and templates write a separate book just about that, just do not mix it with the fun of game making in C++...  Do not get me wrong, its all common sense, if you write a book about apples do not write about cats.

Thanks.
Title: Re: SFML Blueprints - Another SFML book
Post by: Laurent on August 18, 2018, 06:25:31 pm
I've not read it, but as far as I know, SFML Blueprints is not a book for learning how to make a game. It's more about advanced tricks to improve your skills.

Quote from: Packt
Sharpen your game development skills and improve your C++ and SFML knowledge with five exciting projects

Among the 5 books about SFML, it's probably the worst choice for learning SFML & games from scratch. https://www.packtpub.com/game-development/sfml-game-development would have probably been a better choice.
Title: Re: SFML Blueprints - Another SFML book
Post by: Wake on January 27, 2021, 03:37:10 am
Hi, I'm really enjoying the 2nd chapter. However, I'm extremely new to templates and there is so much to do before a single bug test.

I looked at the source code, but I'm at the end of the "Managing user inputs" subchapter.

I moved all the methods for classes using Templates to .tpl files and created the "book namespaces" as you have it.

I'm getting the following error on the "if(action.first.Test())" line. I've checked everything, but the source code provided has the entire chapter's solution. I really want it to compile as you said it should at the end of this subchapter.

Any help would be appreciated.

 Severity   Code   Description   Project   File   Line   Suppression State
Error   C2228   left of '.Test' must have class/struct/union   Chapter 2   C:\Users\lumit\Desktop\SFML Blueprints\Chapter 2\Chapter 2\ActionTarget.tpl   29   


Code: [Select]
template<typename T>
void ActionTarget<T>::ProcessEvents()const
{
    for(auto& action : m_eventsRealTime)
    {
        if(action.first.Test())
           action.second(action.first.m_event);
    }
}