Book Image

SFML Blueprints

Book Image

SFML Blueprints

Overview of this book

Table of Contents (15 chapters)
SFML Blueprints
About the Author
About the Reviewers

Modifying our application

Now that we have all the information required to build our game, let's start to change it. The first step is to change our world to a Euclidean torus with a fixed size. Here is a representation of a torus taken from the Wikipedia page:

To do this, we will need some information from inside the game, such as the world size. We will add the information inside the Game class as two integer values, height and width:

const int _x, const _y;

We will initialize them with the constructor. So now, we need parameters for this class:

Game(int x=800, int y=600);

We will need to change our constructor implementation a bit, as shown in the following code snippet:

Game::Game(int x, int y) : _window(sf::VideoMode(x,y),"03_Asteroid"),x(x),y(y){

Okay, now we can choose the size of the world, but how do we make it a torus? In reality, it's not complicated. We only need to check the position of each entity after moving them; and if they are out of the world...