Coding the main function
What follows is all the code for the main
function. It is also the entire game loop. There is no collision detection, no pause, start, or stop logic, no sprites or textures, no fonts or sounds, and only one line relates to handling input. In this project, everything, or almost everything, will be a game object. Cameras, fireballs, platforms, the player character, the menu, and even the game logic and the rain will be game objects. Exactly how this is achieved is explained over the course of the project, but a good overview will be given in the Entity Component System pattern section later in this chapter. For now, let’s make some progress with the code.
Add the following code to the run.cpp
file in your project and we will then go through it one section at a time:
#pragma once
#include "SFML/Graphics.hpp"
#include <vector>
#include "GameObject.h"
#include "Factory.h"
#include "InputDispatcher.h"...