Lukacms / R-Type

C++ Game Engine with networking

Home Page:https://github.com/Lukacms/R-Type/wiki

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SFML Encapsulation

SamuelFlorentin opened this issue · comments

commented
  • find which functions would be useful to encapsulate
  • create class for common objects (Window, Object, ...)
  • common methods of those class
  • those classes should be loaded in a dynamic library (see here how to do it)

example for a Window class with a draw methods that was for Raytracer:

   class Window
   {
        public:
            Window(sf::VideoMode mode = RAYTRACER_MODE,
                   const std::string &name = RAYTRACER_WINDOW.data());
            Window(Window const &to_copy) = delete;
            Window(Window &&to_move) = delete;
            ~Window() = default;
            Window &operator=(Window const &to_copy) = delete;
            Window &operator=(Window &&to_move) = delete;

            void update();
            void close();
            sf::RenderWindow &getWindow();

            template <typename TObject> void draw(TObject obj)
            {
                this->window.draw(obj);
            }

        private:
            sf::RenderWindow window;
    };