Zmeika
простая аркадная игра
 Указатель Классы Пространства имен Файлы Функции Переменные Определения типов Перечисления Страницы
GameScreen.hpp
См. документацию.
1 /*
2  * This file is part of AV Orchid.
3  * Copyright (c) 2013, Dmitri R. Kuvshinov <evetro.here@gmail.com>
4  *
5  * Permission to use, copy, modify, and/or distribute this software for
6  * any purpose with or without fee is hereby granted, provided that the
7  * above copyright notice and this permission notice appear in all copies.
8  *
9  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16  */
22 #pragma once
23 #include <functional> // std::function
24 
25 #include "Screen.hpp"
26 #include "ViewModelBase.hpp"
27 
28 
30 class GameScreen : public AScreen
31 {
32 public:
33 
34  GameScreen();
35  ~GameScreen() override;
36 
37  // копирование объектов экрана запрещено
38  GameScreen(const GameScreen&) = delete;
39  GameScreen& operator=(const GameScreen&) = delete;
40 
42  using GameOverHandler = std::function<void(Score)>;
43 
46  {
47  doGameOver = handler;
48  }
49 
51  bool isPaused() const;
52 
53 protected:
54 
55  void onSelect() override;
56  void onIdle() override;
57  void onDisplay() override;
58  void onChar(unsigned char code, int mouse_x, int mouse_y) override;
59  void onSpecialKey(int code, int mouse_x, int mouse_y) override;
60  void onMouse(int button, int mouse_x, int mouse_y) override;
61 
62 private:
63  class Game *impl; // pimpl
64  GameOverHandler doGameOver;
65 };