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

Author Topic: SFML Blueprints - Another SFML book  (Read 53846 times)

0 Members and 2 Guests are viewing this topic.

HoodedSpectre

  • Newbie
  • *
  • Posts: 22
    • View Profile
Re: SFML Blueprints - Another SFML book
« Reply #45 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

sandglass

  • Newbie
  • *
  • Posts: 1
    • View Profile
Re: SFML Blueprints - Another SFML book
« Reply #46 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.
« Last Edit: August 18, 2018, 02:50:43 pm by sandglass »

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: SFML Blueprints - Another SFML book
« Reply #47 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.
« Last Edit: August 18, 2018, 06:27:12 pm by Laurent »
Laurent Gomila - SFML developer

Wake

  • Newbie
  • *
  • Posts: 11
    • View Profile
    • Email
Re: SFML Blueprints - Another SFML book
« Reply #48 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);
    }
}