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

Command and Control – Input Handling

Summary

Reading through this chapter, you learned a whole new mechanism to handle input and deliver it correctly to the game's entities. It may not be the simplest concept you will come across, but it certainly pays off later, when you see it under heavier action. Not only have we played with event delivering systems, but we also paid a lot of attention on how to capture input and handle every detail about it. This is essential for every game, after all, who would like to play a game that plays itself?

After having a basic world scene with robust behaviors and features, it is now time to start looking at other phases of a game's development. In other words, the next chapter will cover mechanisms which are not directly related to the game's mechanics and systems, but that instead allow a coherent flow between multiple parts of a game, such as the pause and main menu, the game itself and others that you will encounter. Therefore, expect a lot of interesting information on handling this kind of management that you see in games so often.

[ 112 ]

www.it-ebooks.info

Diverting the Game

Flow – State Stack

In the earlier chapters of this book, you have learned how to make an efficient program structure for a game, modern game loops, and data structures to contain a world with rich graphics. You also learned how to deal with user input, making it an interactive simulation. With the combination of all those pieces of knowledge, we can already make an interesting game experience. However, a game is usually more than that. A full blown product doesn't just open and let you play without an explanation, a menu, or a title screen. That is what is going to be covered in this chapter, the ability to make the game richer by adding different states and screens to it.

The main bits of knowledge to acquire throughout the chapter are as follows:

The state and the stack

Navigating between states

Moving our game into a state

The title screen as the entry point of the game

Our old friend, the main menu

Implementing an overlay pause screen

A simple example of a concurrent loading state

Defining a state

While it is a bit difficult to define correctly what a state actually is, and because that also depends on the implementation we choose to go with, we will try to pass our own idea of what states are and how they should behave.

www.it-ebooks.info

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