Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
SFML Blueprints

You're reading from   SFML Blueprints Sharpen your game development skills and improve your C++ and SFML knowledge with five exciting projects

Arrow left icon
Product type Paperback
Published in May 2015
Publisher Packt
ISBN-13 9781784398477
Length 298 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Toc

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:

Modifying our application

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){
     _player.setPosition(100,100);
}

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...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at AU $24.99/month. Cancel anytime