Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
SFML Game Development.pdf
Скачиваний:
194
Добавлен:
28.03.2016
Размер:
4.19 Mб
Скачать

Chapter 2

Using the new ResourceHolder class template, we can visualize a possible in-game situation in the following diagram. On the left you see two resource holders, one for textures and one for fonts. Each one contains a map of enumerators to resources. The player's Aircraft class on the right stores a sprite that points to a texture, as well as a text that points to a font.

ResourceHolder<sf::Texture, Textures::ID>

 

Landscape

sf::Texture

Aircraft

 

 

Airplane

sf::Texture

sf::Sprite

Missile

sf::Texture

sf::Text

ResourceHolder<sf::Font, Fonts::ID>

 

Arial

sf::Font

 

Times

sf::Font

 

Summary

In this chapter, we have learned the important points about resource management. By now, we know the ideas behind resources and the facilities SFML provides to work with them. We have taken a look at a possible way resources are used in a bigger project, and implemented a generic resource holder that helps us with passing resources to different parts of the application. We also investigated possible error sources as well as techniques to handle them appropriately.

In the next chapter, we are going to develop the game world with a variety of objects in it. Most of these objects require different resources, which is a good opportunity to show our resource holder in a real-world example.

[ 47 ]

www.it-ebooks.info

www.it-ebooks.info

Forge of the Gods – Shaping

Our World

In the previous chapter, we have covered loading, managing, and releasing of external resources. To sum up, we have investigated mechanisms to ensure that textures, fonts, or sounds are ready to be used as soon as we need them. This chapter attempts to bring knowledge around a few key topics:

Entity systems in concept and practice

The viewable area of our world and scrolling

Tree-based scene graphs, rendering and updating of many entities

Composition of all elements to shape the world

When writing a game, we invariably find the need to conceptualize our vision of the game into actual data structures. In other words, it is extremely important to have a clear idea of the scope of our vision. The world in our mind doesn't even have

to scale remotely to what we consider our real world; it is a product of our own creation. It is well within our power, as game developers, to forge the whole world as a simple board game table, or an ant farm, or even scale up to a whole universe along with all the stars and planets.

The point is, it does not matter how our vision of the world looks, how small or big it is, or how realistic or abstract the concepts in it are, we will always want to represent that world in one or more data structures. For the reach of this book, we will apply these concepts directly to our own sample vision of a game, while leaving a solid background on the topic, for later implementation of new ideas and concepts.

www.it-ebooks.info

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]