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

Chapter 7

handleCollisions();

mSceneGraph.removeWrecks();

spawnEnemies();

mSceneGraph.update(dt, mCommandQueue); adaptPlayerPosition();

}

Victory and defeat

Equipped with the Eagle aircraft, you can accept the challenge to maneuver through a mission. Depending on your skill, you may reach the end of the level and become a pilot legend. Or you fall victim to the enemy fleet and die in a horrible plane crash.

Anyway, the player should be informed by the game about his fate. In most games, there are victory and defeat conditions. In our airplane game, a mission is complete if you cross the level's border at the end. A mission is failed if your plane is destroyed. To display this information, we have written GameOverState that displays an appropriate message. Of course, this can be extended to show high scores, statistics, or save the game between multiple missions. But the basic principle remains

the same. We reuse the states and GUI from the previous chapters. Since their implementation should be clear, we do not paste their code here. However, you are free to look at the original code base at any time.

Summary

This was probably the most difficult chapter up to now, as it combines all the game- related features we have developed in earlier chapters: resources, world, entities, input, and commands. Despite all the things to consider, it became apparent that the existing framework made a lot of new tasks simple to achieve.

In this chapter, you learned about essential gameplay mechanics and their interaction. We added projectiles to represent bullets and homing missiles. We let enemies spawn, follow certain movement patterns, fire in regular intervals, and drop pickups upon destruction. Collision detection and response was implemented, and we discussed performance considerations. Eventually, we managed the world's update cycle, and cleaned up destroyed entities.

Now that the game foundation has been built, we are ready to add more graphical content. In the next chapter, we are going to add a variety of visual effects to improve the appearance of our game.

[ 183 ]

www.it-ebooks.info

www.it-ebooks.info

Every Pixel Counts – Adding

Visual Effects

Throughout the previous chapters, we have constantly been adding functionality.

We finally reached a point where our game is playable, where all the game mechanisms are implemented. With a bit of creativity, you should already be able to write your own small game. Nevertheless, we are not going to quit now—a game is more than just gameplay. A very important part of games are the graphics. Be

it cutting-edge 3D scenes in the newest real-time strategy game or the nostalgic atmosphere of a pixel-art indie title, graphics determine to a big extent how the player feels.

In this chapter, we are going to look behind the scenes of rendering. We are going to cover various techniques that are used in modern games to create graphical effects of different kinds. To mention a few:

Texture atlases and how different objects can be stored in one texture

Texture mapping and vertex arrays

Particle systems to create effects such as fire or smoke

Animations that show an object in motion

Render textures as an alternative to render windows

Shaders to give the whole scene a distinct look

While the previous chapter concerned gameplay and therefore didn't work a lot with SFML, this one will introduce many new features of its Graphics module.

www.it-ebooks.info

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