Coding the Factory class
Create a new class called Factory. In the Factory.h file, add the following code.
#pragma once
#include <vector>
#include "GameObject.h"
#include "SFML/Graphics.hpp"
using namespace sf;
using namespace std;
class InputDispatcher;
class Factory
{
private:
RenderWindow* m_Window;
public:
Factory(RenderWindow* window);
void loadLevel(
vector <GameObject>& gameObjects,
VertexArray& canvas,
InputDispatcher& inputDispatcher);
Texture* m_Texture;
};
In the preceding code, the Factory class is declared and a private RenderWindow pointer is as well.
Note this will be initialized to point to the same RenderWindow instance from the main function and the same RenderWindow instance from the InputDispatcher class. There are three functions: the constructor that receives the RenderWindow address, the loadLevel function that receives the vector of GameObject instances, the VertexArray for drawing...